Skip to content

Commit

Permalink
fix: stabilitze UTs (#4180)
Browse files Browse the repository at this point in the history
  • Loading branch information
kobenguyent authored Feb 5, 2024
1 parent ced73e8 commit 226e2e5
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions test/runner/timeout_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});

0 comments on commit 226e2e5

Please sign in to comment.