-
-
Notifications
You must be signed in to change notification settings - Fork 752
Expand file tree
/
Copy pathstep_timeout_test.js
More file actions
72 lines (64 loc) · 2.76 KB
/
step_timeout_test.js
File metadata and controls
72 lines (64 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import * as chai from 'chai'
chai.should()
import { expect } from 'expect'
import { exec } from 'child_process'
import path from 'path'
import figures from 'figures'
import { codecept_dir, codecept_run } from './consts.js'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const debug_this_test = false
const config_run_config = (config, grep, verbose = false) => `${codecept_run} ${verbose || debug_this_test ? '--verbose' : ''} --config ${codecept_dir}/configs/step_timeout/${config} ${grep ? `--grep "${grep}"` : ''}`
describe('CodeceptJS Steps', function () {
this.timeout(5000)
it('should stop test, when step timeout exceeded', done => {
exec(config_run_config('codecept-1000.conf.js', 'Default command timeout'), (err, stdout) => {
expect(stdout).toContain('Action exceededByTimeout: 1500 was interrupted on timeout 1000ms')
expect(stdout).toContain('0 passed, 1 failed')
expect(stdout).toContain(figures.cross + ' I.exceededByTimeout(1500)')
expect(err).toBeTruthy()
done()
})
})
it('should respect custom timeout with regex', done => {
exec(config_run_config('codecept-1000.conf.js', 'Wait with longer timeout', debug_this_test), (err, stdout) => {
expect(stdout).not.toContain('was interrupted on timeout')
expect(stdout).toContain('1 passed')
expect(err).toBeFalsy()
done()
})
})
it('should respect custom timeout with full step name', done => {
exec(config_run_config('codecept-1000.conf.js', 'Wait with shorter timeout', debug_this_test), (err, stdout) => {
expect(stdout).toContain('Action waitTadShorter: 750 was interrupted on timeout 500ms')
expect(stdout).toContain('0 passed, 1 failed')
expect(err).toBeTruthy()
done()
})
})
it('should not stop test, when step not exceeded', done => {
exec(config_run_config('codecept-2000.conf.js', 'Default command timeout'), (err, stdout) => {
expect(stdout).not.toContain('was interrupted on timeout')
expect(stdout).toContain('1 passed')
expect(err).toBeFalsy()
done()
})
})
it('should ignore timeout for steps with `wait*` prefix', done => {
exec(config_run_config('codecept-1000.conf.js', 'Wait command timeout'), (err, stdout) => {
expect(stdout).not.toContain('was interrupted on timeout')
expect(stdout).toContain('1 passed')
expect(err).toBeFalsy()
done()
})
})
it('step timeout should work nicely with step retries', done => {
exec(config_run_config('codecept-1000.conf.js', 'Rerun sleep'), (err, stdout) => {
expect(stdout).not.toContain('was interrupted on timeout')
expect(stdout).toContain('1 passed')
expect(err).toBeFalsy()
done()
})
})
})