-
-
Notifications
You must be signed in to change notification settings - Fork 752
Expand file tree
/
Copy pathpauseOnFail.js
More file actions
43 lines (37 loc) · 838 Bytes
/
Copy pathpauseOnFail.js
File metadata and controls
43 lines (37 loc) · 838 Bytes
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
import event from '../event.js'
import pause from '../pause.js'
/**
* Automatically launches [interactive pause](/basics/#pause) when a test fails.
*
* Useful for debugging flaky tests on local environment.
* Add this plugin to config file:
*
* ```js
* plugins: {
* pauseOnFail: {},
* }
* ```
*
* Unlike other plugins, `pauseOnFail` is not recommended to be enabled by default.
* Enable it manually on each run via `-p` option:
*
* ```
* npx codeceptjs run -p pauseOnFail
* ```
*
*/
const defaultConfig = {
runInParent: false,
}
export default function(config) {
let failed = false
event.dispatcher.on(event.test.started, () => {
failed = false
})
event.dispatcher.on(event.step.failed, () => {
failed = true
})
event.dispatcher.on(event.test.after, () => {
if (failed) pause()
})
}