From 226e2e5f5ef99ced0b43896a0fe169384009bb86 Mon Sep 17 00:00:00 2001 From: KobeN <7845001+kobenguyent@users.noreply.github.com> Date: Mon, 5 Feb 2024 12:41:53 +0100 Subject: [PATCH] fix: stabilitze UTs (#4180) --- test/runner/timeout_test.js | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/test/runner/timeout_test.js b/test/runner/timeout_test.js index 79d74f054..4c0d0e53e 100644 --- a/test/runner/timeout_test.js +++ b/test/runner/timeout_test.js @@ -9,89 +9,80 @@ const config_run_config = (config, grep, verbose = false) => `${codecept_run} ${ describe('CodeceptJS Timeouts', function () { this.timeout(10000); - it('should stop test when timeout exceeded', (done) => { + it('should stop test when timeout exceeded', () => { exec(config_run_config('codecept.conf.js', 'timed out'), (err, stdout) => { console.log(stdout); expect(stdout).toContain('Timeout 2s exceeded'); expect(stdout).toContain('Timeout 1s exceeded'); expect(err).toBeTruthy(); - done(); }); }); - it('should take --no-timeouts option', (done) => { + it('should take --no-timeouts option', () => { exec(`${config_run_config('codecept.conf.js', 'timed out')} --no-timeouts`, (err, stdout) => { debug_this_test && console.log(stdout); expect(stdout).toContain('Timeouts were disabled'); expect(stdout).not.toContain('Timeout 2s exceeded'); expect(stdout).not.toContain('Timeout 1s exceeded'); expect(err).toBeFalsy(); - done(); }); }); - it('should ignore timeouts if no timeout', (done) => { + it('should ignore timeouts if no timeout', () => { exec(config_run_config('codecept.conf.js', 'no timeout test'), (err, stdout) => { debug_this_test && console.log(stdout); expect(stdout).not.toContain('Timeout'); expect(err).toBeFalsy(); - done(); }); }); - it('should use global timeouts if timeout is set', (done) => { + it('should use global timeouts if timeout is set', () => { exec(config_run_config('codecept.timeout.conf.js', 'no timeout test'), (err, stdout) => { debug_this_test && console.log(stdout); expect(stdout).toContain('Timeout 0.1'); expect(err).toBeTruthy(); - done(); }); }); - it('should prefer step timeout', (done) => { + it('should prefer step timeout', () => { exec(config_run_config('codecept.conf.js', 'timeout step', true), (err, stdout) => { debug_this_test && console.log(stdout); expect(stdout).toContain('was interrupted on step timeout 100ms'); expect(err).toBeTruthy(); - done(); }); }); - it('should keep timeout with steps', (done) => { + it('should keep timeout with steps', () => { exec(config_run_config('codecept.timeout.conf.js', 'timeout step', true), (err, stdout) => { debug_this_test && console.log(stdout); expect(stdout).toContain('was interrupted on step timeout 100ms'); expect(err).toBeTruthy(); - done(); }); }); - it('should override timeout config from global object', (done) => { + it('should override timeout config from global object', () => { exec(config_run_config('codecept.timeout.obj.conf.js', '#first', false), (err, stdout) => { debug_this_test && console.log(stdout); expect(stdout).toContain('Timeout 0.3s exceeded'); expect(err).toBeTruthy(); - done(); }); }); - it('should override timeout config from global object but respect local value', (done) => { + it('should override timeout config from global object but respect local value', () => { exec(config_run_config('codecept.timeout.obj.conf.js', '#second'), (err, stdout) => { debug_this_test && console.log(stdout); expect(stdout).not.toContain('Timeout 0.3s exceeded'); expect(stdout).toContain('Timeout 0.5s exceeded'); expect(err).toBeTruthy(); - done(); }); }); - it('should respect grep when overriding config from global config', (done) => { + it('should respect grep when overriding config from global config', () => { exec(config_run_config('codecept.timeout.obj.conf.js', '#fourth'), (err, stdout) => { debug_this_test && console.log(stdout); expect(stdout).not.toContain('Timeout 0.3s exceeded'); expect(stdout).toContain('Timeout 1s exceeded'); expect(err).toBeTruthy(); - done(); }); }); });