codeceptjs 4.0.0-beta.2 → 4.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/bin/codecept.js +84 -81
- package/lib/actor.js +13 -13
- package/lib/ai.js +10 -13
- package/lib/assert/empty.js +20 -21
- package/lib/assert/equal.js +37 -39
- package/lib/assert/error.js +14 -14
- package/lib/assert/include.js +46 -47
- package/lib/assert/throws.js +13 -11
- package/lib/assert/truth.js +19 -22
- package/lib/assert.js +4 -2
- package/lib/cli.js +56 -49
- package/lib/codecept.js +145 -155
- package/lib/colorUtils.js +3 -3
- package/lib/command/configMigrate.js +58 -52
- package/lib/command/definitions.js +88 -89
- package/lib/command/dryRun.js +79 -81
- package/lib/command/generate.js +197 -188
- package/lib/command/gherkin/init.js +27 -16
- package/lib/command/gherkin/snippets.js +21 -21
- package/lib/command/gherkin/steps.js +8 -8
- package/lib/command/info.js +40 -38
- package/lib/command/init.js +290 -288
- package/lib/command/interactive.js +32 -32
- package/lib/command/list.js +26 -26
- package/lib/command/run-multiple/chunk.js +5 -5
- package/lib/command/run-multiple/collection.js +3 -3
- package/lib/command/run-multiple/run.js +6 -2
- package/lib/command/run-multiple.js +113 -93
- package/lib/command/run-rerun.js +20 -25
- package/lib/command/run-workers.js +64 -66
- package/lib/command/run.js +26 -29
- package/lib/command/utils.js +80 -65
- package/lib/command/workers/runTests.js +11 -12
- package/lib/config.js +10 -9
- package/lib/container.js +40 -48
- package/lib/data/context.js +60 -59
- package/lib/data/dataScenarioConfig.js +47 -47
- package/lib/data/dataTableArgument.js +29 -29
- package/lib/data/table.js +26 -20
- package/lib/event.js +163 -167
- package/lib/heal.js +14 -18
- package/lib/helper/AI.js +130 -41
- package/lib/helper/ApiDataFactory.js +74 -70
- package/lib/helper/Appium.js +416 -388
- package/lib/helper/ExpectHelper.js +40 -48
- package/lib/helper/FileSystem.js +80 -79
- package/lib/helper/GraphQL.js +44 -43
- package/lib/helper/GraphQLDataFactory.js +51 -51
- package/lib/helper/JSONResponse.js +65 -62
- package/lib/helper/Mochawesome.js +28 -28
- package/lib/helper/Nightmare.js +664 -571
- package/lib/helper/Playwright.js +1367 -1222
- package/lib/helper/Protractor.js +663 -635
- package/lib/helper/Puppeteer.js +1232 -1132
- package/lib/helper/REST.js +183 -68
- package/lib/helper/SoftExpectHelper.js +2 -2
- package/lib/helper/TestCafe.js +490 -486
- package/lib/helper/WebDriver.js +1246 -1297
- package/lib/helper/clientscripts/PollyWebDriverExt.js +1 -1
- package/lib/helper/errors/ConnectionRefused.js +1 -1
- package/lib/helper/errors/ElementAssertion.js +2 -2
- package/lib/helper/errors/ElementNotFound.js +2 -2
- package/lib/helper/errors/RemoteBrowserConnectionRefused.js +1 -1
- package/lib/helper/extras/Console.js +1 -1
- package/lib/helper/extras/PlaywrightPropEngine.js +4 -4
- package/lib/helper/extras/PlaywrightReactVueLocator.js +1 -1
- package/lib/helper/extras/PlaywrightRestartOpts.js +21 -18
- package/lib/helper/extras/Popup.js +1 -1
- package/lib/helper/extras/React.js +3 -3
- package/lib/helper/network/actions.js +14 -7
- package/lib/helper/network/utils.js +4 -3
- package/lib/helper/scripts/blurElement.js +1 -1
- package/lib/helper/scripts/focusElement.js +1 -1
- package/lib/helper/scripts/highlightElement.js +1 -1
- package/lib/helper/scripts/isElementClickable.js +1 -1
- package/lib/helper/testcafe/testControllerHolder.js +1 -1
- package/lib/helper/testcafe/testcafe-utils.js +7 -8
- package/lib/helper.js +1 -3
- package/lib/history.js +6 -5
- package/lib/hooks.js +6 -6
- package/lib/html.js +7 -7
- package/lib/index.js +25 -41
- package/lib/interfaces/bdd.js +47 -64
- package/lib/interfaces/featureConfig.js +19 -19
- package/lib/interfaces/gherkin.js +124 -118
- package/lib/interfaces/scenarioConfig.js +29 -29
- package/lib/listener/artifacts.js +9 -9
- package/lib/listener/config.js +24 -24
- package/lib/listener/exit.js +12 -12
- package/lib/listener/helpers.js +42 -42
- package/lib/listener/mocha.js +11 -11
- package/lib/listener/retry.js +32 -30
- package/lib/listener/steps.js +50 -53
- package/lib/listener/timeout.js +54 -54
- package/lib/locator.js +7 -11
- package/lib/mochaFactory.js +18 -15
- package/lib/output.js +19 -15
- package/lib/parser.js +15 -12
- package/lib/pause.js +45 -38
- package/lib/plugin/allure.js +15 -15
- package/lib/plugin/autoDelay.js +29 -37
- package/lib/plugin/autoLogin.js +70 -65
- package/lib/plugin/commentStep.js +18 -18
- package/lib/plugin/coverage.js +112 -67
- package/lib/plugin/customLocator.js +21 -20
- package/lib/plugin/debugErrors.js +24 -24
- package/lib/plugin/eachElement.js +38 -38
- package/lib/plugin/fakerTransform.js +6 -6
- package/lib/plugin/heal.js +67 -108
- package/lib/plugin/pauseOnFail.js +11 -11
- package/lib/plugin/retryFailedStep.js +32 -39
- package/lib/plugin/retryTo.js +46 -40
- package/lib/plugin/screenshotOnFail.js +109 -87
- package/lib/plugin/selenoid.js +131 -118
- package/lib/plugin/standardActingHelpers.js +2 -8
- package/lib/plugin/stepByStepReport.js +110 -91
- package/lib/plugin/stepTimeout.js +24 -23
- package/lib/plugin/subtitles.js +34 -35
- package/lib/plugin/tryTo.js +40 -30
- package/lib/plugin/wdio.js +78 -75
- package/lib/recorder.js +14 -17
- package/lib/rerun.js +11 -10
- package/lib/scenario.js +25 -23
- package/lib/secret.js +4 -3
- package/lib/session.js +10 -10
- package/lib/step.js +12 -9
- package/lib/store.js +2 -3
- package/lib/transform.js +1 -1
- package/lib/translation.js +7 -8
- package/lib/ui.js +12 -14
- package/lib/utils.js +70 -72
- package/lib/within.js +10 -10
- package/lib/workerStorage.js +27 -25
- package/lib/workers.js +29 -33
- package/package.json +67 -68
- package/translations/de-DE.js +2 -1
- package/translations/fr-FR.js +2 -2
- package/translations/index.js +9 -13
- package/translations/it-IT.js +1 -1
- package/translations/ja-JP.js +1 -1
- package/translations/pl-PL.js +1 -1
- package/translations/pt-BR.js +1 -1
- package/translations/ru-RU.js +1 -1
- package/translations/zh-CN.js +1 -1
- package/translations/zh-TW.js +1 -1
- package/typings/index.d.ts +423 -65
- package/typings/promiseBasedTypes.d.ts +41 -172
- package/typings/types.d.ts +43 -178
- package/lib/dirname.js +0 -5
- package/lib/helper/Expect.js +0 -425
- package/lib/helper/MockServer.js +0 -223
package/lib/data/table.js
CHANGED
|
@@ -4,40 +4,46 @@
|
|
|
4
4
|
class DataTable {
|
|
5
5
|
/** @param {Array<*>} array */
|
|
6
6
|
constructor(array) {
|
|
7
|
-
this.array = array
|
|
8
|
-
this.rows = new Array(0)
|
|
7
|
+
this.array = array
|
|
8
|
+
this.rows = new Array(0)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/** @param {Array<*>} array */
|
|
12
12
|
add(array) {
|
|
13
|
-
if (array.length !== this.array.length)
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (array.length !== this.array.length)
|
|
14
|
+
throw new Error(
|
|
15
|
+
`There is too many elements in given data array. Please provide data in this format: ${this.array}`,
|
|
16
|
+
)
|
|
17
|
+
const tempObj = {}
|
|
18
|
+
let arrayCounter = 0
|
|
16
19
|
this.array.forEach((elem) => {
|
|
17
|
-
tempObj[elem] = array[arrayCounter]
|
|
18
|
-
tempObj.toString = () => JSON.stringify(tempObj)
|
|
19
|
-
arrayCounter
|
|
20
|
-
})
|
|
21
|
-
this.rows.push({ skip: false, data: tempObj })
|
|
20
|
+
tempObj[elem] = array[arrayCounter]
|
|
21
|
+
tempObj.toString = () => JSON.stringify(tempObj)
|
|
22
|
+
arrayCounter++
|
|
23
|
+
})
|
|
24
|
+
this.rows.push({ skip: false, data: tempObj })
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
/** @param {Array<*>} array */
|
|
25
28
|
xadd(array) {
|
|
26
|
-
if (array.length !== this.array.length)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
if (array.length !== this.array.length)
|
|
30
|
+
throw new Error(
|
|
31
|
+
`There is too many elements in given data array. Please provide data in this format: ${this.array}`,
|
|
32
|
+
)
|
|
33
|
+
const tempObj = {}
|
|
34
|
+
let arrayCounter = 0
|
|
29
35
|
this.array.forEach((elem) => {
|
|
30
|
-
tempObj[elem] = array[arrayCounter]
|
|
31
|
-
tempObj.toString = () => JSON.stringify(tempObj)
|
|
32
|
-
arrayCounter
|
|
33
|
-
})
|
|
34
|
-
this.rows.push({ skip: true, data: tempObj })
|
|
36
|
+
tempObj[elem] = array[arrayCounter]
|
|
37
|
+
tempObj.toString = () => JSON.stringify(tempObj)
|
|
38
|
+
arrayCounter++
|
|
39
|
+
})
|
|
40
|
+
this.rows.push({ skip: true, data: tempObj })
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
/** @param {Function} func */
|
|
38
44
|
filter(func) {
|
|
39
|
-
return this.rows.filter(row => func(row.data))
|
|
45
|
+
return this.rows.filter((row) => func(row.data))
|
|
40
46
|
}
|
|
41
47
|
}
|
|
42
48
|
|
|
43
|
-
|
|
49
|
+
module.exports = DataTable
|
package/lib/event.js
CHANGED
|
@@ -1,176 +1,172 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import * as output from './output.js';
|
|
5
|
-
|
|
6
|
-
debug('codeceptjs:event');
|
|
1
|
+
const debug = require('debug')('codeceptjs:event');
|
|
2
|
+
const events = require('events');
|
|
3
|
+
const { error } = require('./output');
|
|
7
4
|
|
|
8
5
|
const dispatcher = new events.EventEmitter();
|
|
9
6
|
|
|
10
7
|
dispatcher.setMaxListeners(50);
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @type {object}
|
|
14
|
-
* @constant
|
|
15
|
-
* @inner
|
|
16
|
-
* @property {'test.start'} started
|
|
17
|
-
* @property {'test.before'} before
|
|
18
|
-
* @property {'test.after'} after
|
|
19
|
-
* @property {'test.passed'} passed
|
|
20
|
-
* @property {'test.failed'} failed
|
|
21
|
-
* @property {'test.finish'} finished
|
|
22
|
-
* @property {'test.skipped'} skipped
|
|
23
|
-
*/
|
|
24
|
-
export const test = {
|
|
25
|
-
started: 'test.start', // sync
|
|
26
|
-
before: 'test.before', // async
|
|
27
|
-
after: 'test.after', // async
|
|
28
|
-
passed: 'test.passed', // sync
|
|
29
|
-
failed: 'test.failed', // sync
|
|
30
|
-
finished: 'test.finish', // sync
|
|
31
|
-
skipped: 'test.skipped', // sync
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @type {object}
|
|
36
|
-
* @constant
|
|
37
|
-
* @inner
|
|
38
|
-
* @property {'suite.before'} before
|
|
39
|
-
* @property {'suite.after'} after
|
|
40
|
-
*/
|
|
41
|
-
export const suite = {
|
|
42
|
-
before: 'suite.before',
|
|
43
|
-
after: 'suite.after',
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* @type {object}
|
|
47
|
-
* @constant
|
|
48
|
-
* @inner
|
|
49
|
-
* @property {'hook.start'} started
|
|
50
|
-
* @property {'hook.passed'} passed
|
|
51
|
-
*/
|
|
52
|
-
export const hook = {
|
|
53
|
-
started: 'hook.start',
|
|
54
|
-
passed: 'hook.passed',
|
|
55
|
-
failed: 'hook.failed',
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* @type {object}
|
|
59
|
-
* @constant
|
|
60
|
-
* @inner
|
|
61
|
-
* @property {'step.start'} started
|
|
62
|
-
* @property {'step.before'} before
|
|
63
|
-
* @property {'step.after'} after
|
|
64
|
-
* @property {'step.passed'} passed
|
|
65
|
-
* @property {'step.failed'} failed
|
|
66
|
-
* @property {'step.finish'} finished
|
|
67
|
-
* @property {'step.comment'} comment
|
|
68
|
-
*/
|
|
69
|
-
export const step = {
|
|
70
|
-
before: 'step.before', // async
|
|
71
|
-
after: 'step.after', // async
|
|
72
|
-
started: 'step.start', // sync
|
|
73
|
-
passed: 'step.passed', // sync
|
|
74
|
-
failed: 'step.failed', // sync
|
|
75
|
-
finished: 'step.finish', // sync
|
|
76
|
-
comment: 'step.comment',
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* @type {object}
|
|
80
|
-
* @constant
|
|
81
|
-
* @inner
|
|
82
|
-
* @property {'suite.before'} before
|
|
83
|
-
* @property {'suite.after'} after
|
|
84
|
-
*/
|
|
85
|
-
export const bddStep = {
|
|
86
|
-
before: 'bddStep.before',
|
|
87
|
-
after: 'bddStep.after',
|
|
88
|
-
started: 'bddStep.started',
|
|
89
|
-
finished: 'bddStep.finished',
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* @type {object}
|
|
93
|
-
* @constant
|
|
94
|
-
* @inner
|
|
95
|
-
* @property {'global.before'} before
|
|
96
|
-
* @property {'global.after'} after
|
|
97
|
-
* @property {'global.result'} result
|
|
98
|
-
* @property {'global.failures'} failures
|
|
99
|
-
*/
|
|
100
|
-
export const all = {
|
|
101
|
-
before: 'global.before',
|
|
102
|
-
after: 'global.after',
|
|
103
|
-
result: 'global.result',
|
|
104
|
-
failures: 'global.failures',
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* @type {object}
|
|
108
|
-
* @constant
|
|
109
|
-
* @inner
|
|
110
|
-
* @property {'multiple.before'} before
|
|
111
|
-
* @property {'multiple.after'} after
|
|
112
|
-
*/
|
|
113
|
-
export const multiple = {
|
|
114
|
-
before: 'multiple.before',
|
|
115
|
-
after: 'multiple.after',
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* @type {object}
|
|
120
|
-
* @constant
|
|
121
|
-
* @inner
|
|
122
|
-
* @property {'workers.before'} before
|
|
123
|
-
* @property {'workers.after'} after
|
|
124
|
-
* @property {'workers.result'} result
|
|
125
|
-
*/
|
|
126
|
-
export const workers = {
|
|
127
|
-
before: 'workers.before',
|
|
128
|
-
after: 'workers.after',
|
|
129
|
-
result: 'workers.result',
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
/** for testing only! */
|
|
133
|
-
export function cleanDispatcher() {
|
|
134
|
-
let event;
|
|
135
|
-
for (event in test) {
|
|
136
|
-
dispatcher.removeAllListeners(test[event]);
|
|
137
|
-
}
|
|
138
|
-
for (event in suite) {
|
|
139
|
-
dispatcher.removeAllListeners(test[event]);
|
|
140
|
-
}
|
|
141
|
-
for (event in step) {
|
|
142
|
-
dispatcher.removeAllListeners(test[event]);
|
|
143
|
-
}
|
|
144
|
-
for (event in all) {
|
|
145
|
-
dispatcher.removeAllListeners(test[event]);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
8
|
/**
|
|
150
9
|
* @namespace
|
|
151
10
|
* @alias event
|
|
152
11
|
*/
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
12
|
+
module.exports = {
|
|
13
|
+
/**
|
|
14
|
+
* @type {NodeJS.EventEmitter}
|
|
15
|
+
* @constant
|
|
16
|
+
* @inner
|
|
17
|
+
*/
|
|
18
|
+
dispatcher,
|
|
19
|
+
/**
|
|
20
|
+
* @type {object}
|
|
21
|
+
* @constant
|
|
22
|
+
* @inner
|
|
23
|
+
* @property {'test.start'} started
|
|
24
|
+
* @property {'test.before'} before
|
|
25
|
+
* @property {'test.after'} after
|
|
26
|
+
* @property {'test.passed'} passed
|
|
27
|
+
* @property {'test.failed'} failed
|
|
28
|
+
* @property {'test.finish'} finished
|
|
29
|
+
* @property {'test.skipped'} skipped
|
|
30
|
+
*/
|
|
31
|
+
test: {
|
|
32
|
+
started: 'test.start', // sync
|
|
33
|
+
before: 'test.before', // async
|
|
34
|
+
after: 'test.after', // async
|
|
35
|
+
passed: 'test.passed', // sync
|
|
36
|
+
failed: 'test.failed', // sync
|
|
37
|
+
finished: 'test.finish', // sync
|
|
38
|
+
skipped: 'test.skipped', // sync
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* @type {object}
|
|
42
|
+
* @constant
|
|
43
|
+
* @inner
|
|
44
|
+
* @property {'suite.before'} before
|
|
45
|
+
* @property {'suite.after'} after
|
|
46
|
+
*/
|
|
47
|
+
suite: {
|
|
48
|
+
before: 'suite.before',
|
|
49
|
+
after: 'suite.after',
|
|
50
|
+
},
|
|
51
|
+
/**
|
|
52
|
+
* @type {object}
|
|
53
|
+
* @constant
|
|
54
|
+
* @inner
|
|
55
|
+
* @property {'hook.start'} started
|
|
56
|
+
* @property {'hook.passed'} passed
|
|
57
|
+
*/
|
|
58
|
+
hook: {
|
|
59
|
+
started: 'hook.start',
|
|
60
|
+
passed: 'hook.passed',
|
|
61
|
+
failed: 'hook.failed',
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* @type {object}
|
|
65
|
+
* @constant
|
|
66
|
+
* @inner
|
|
67
|
+
* @property {'step.start'} started
|
|
68
|
+
* @property {'step.before'} before
|
|
69
|
+
* @property {'step.after'} after
|
|
70
|
+
* @property {'step.passed'} passed
|
|
71
|
+
* @property {'step.failed'} failed
|
|
72
|
+
* @property {'step.finish'} finished
|
|
73
|
+
* @property {'step.comment'} comment
|
|
74
|
+
*/
|
|
75
|
+
step: {
|
|
76
|
+
before: 'step.before', // async
|
|
77
|
+
after: 'step.after', // async
|
|
78
|
+
started: 'step.start', // sync
|
|
79
|
+
passed: 'step.passed', // sync
|
|
80
|
+
failed: 'step.failed', // sync
|
|
81
|
+
finished: 'step.finish', // sync
|
|
82
|
+
comment: 'step.comment',
|
|
83
|
+
},
|
|
84
|
+
/**
|
|
85
|
+
* @type {object}
|
|
86
|
+
* @constant
|
|
87
|
+
* @inner
|
|
88
|
+
* @property {'suite.before'} before
|
|
89
|
+
* @property {'suite.after'} after
|
|
90
|
+
*/
|
|
91
|
+
bddStep: {
|
|
92
|
+
before: 'bddStep.before',
|
|
93
|
+
after: 'bddStep.after',
|
|
94
|
+
started: 'bddStep.started',
|
|
95
|
+
finished: 'bddStep.finished',
|
|
96
|
+
},
|
|
97
|
+
/**
|
|
98
|
+
* @type {object}
|
|
99
|
+
* @constant
|
|
100
|
+
* @inner
|
|
101
|
+
* @property {'global.before'} before
|
|
102
|
+
* @property {'global.after'} after
|
|
103
|
+
* @property {'global.result'} result
|
|
104
|
+
* @property {'global.failures'} failures
|
|
105
|
+
*/
|
|
106
|
+
all: {
|
|
107
|
+
before: 'global.before',
|
|
108
|
+
after: 'global.after',
|
|
109
|
+
result: 'global.result',
|
|
110
|
+
failures: 'global.failures',
|
|
111
|
+
},
|
|
112
|
+
/**
|
|
113
|
+
* @type {object}
|
|
114
|
+
* @constant
|
|
115
|
+
* @inner
|
|
116
|
+
* @property {'multiple.before'} before
|
|
117
|
+
* @property {'multiple.after'} after
|
|
118
|
+
*/
|
|
119
|
+
multiple: {
|
|
120
|
+
before: 'multiple.before',
|
|
121
|
+
after: 'multiple.after',
|
|
122
|
+
},
|
|
159
123
|
|
|
160
|
-
/**
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
124
|
+
/**
|
|
125
|
+
* @type {object}
|
|
126
|
+
* @constant
|
|
127
|
+
* @inner
|
|
128
|
+
* @property {'workers.before'} before
|
|
129
|
+
* @property {'workers.after'} after
|
|
130
|
+
* @property {'workers.result'} result
|
|
131
|
+
*/
|
|
132
|
+
workers: {
|
|
133
|
+
before: 'workers.before',
|
|
134
|
+
after: 'workers.after',
|
|
135
|
+
result: 'workers.result',
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @param {string} event
|
|
140
|
+
* @param {*} [param]
|
|
141
|
+
*/
|
|
142
|
+
emit(event, param) {
|
|
143
|
+
let msg = `Emitted | ${event}`;
|
|
144
|
+
if (param && param.toString()) {
|
|
145
|
+
msg += ` (${param.toString()})`;
|
|
146
|
+
}
|
|
147
|
+
debug(msg);
|
|
148
|
+
try {
|
|
149
|
+
this.dispatcher.emit.apply(this.dispatcher, arguments);
|
|
150
|
+
} catch (err) {
|
|
151
|
+
error(`Error processing ${event} event:`);
|
|
152
|
+
error(err.stack);
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
/** for testing only! */
|
|
157
|
+
cleanDispatcher: () => {
|
|
158
|
+
let event;
|
|
159
|
+
for (event in this.test) {
|
|
160
|
+
this.dispatcher.removeAllListeners(this.test[event]);
|
|
161
|
+
}
|
|
162
|
+
for (event in this.suite) {
|
|
163
|
+
this.dispatcher.removeAllListeners(this.test[event]);
|
|
164
|
+
}
|
|
165
|
+
for (event in this.step) {
|
|
166
|
+
this.dispatcher.removeAllListeners(this.test[event]);
|
|
167
|
+
}
|
|
168
|
+
for (event in this.all) {
|
|
169
|
+
this.dispatcher.removeAllListeners(this.test[event]);
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
};
|
package/lib/heal.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const logger = debug('myapp:server');
|
|
9
|
-
|
|
10
|
-
logger('codeceptjs:heal');
|
|
1
|
+
const debug = require('debug')('codeceptjs:heal');
|
|
2
|
+
const colors = require('chalk');
|
|
3
|
+
const Container = require('./container');
|
|
4
|
+
const recorder = require('./recorder');
|
|
5
|
+
const output = require('./output');
|
|
6
|
+
const event = require('./event');
|
|
11
7
|
|
|
12
8
|
/**
|
|
13
9
|
* @class
|
|
@@ -61,7 +57,7 @@ class Heal {
|
|
|
61
57
|
const suggestions = [];
|
|
62
58
|
const recipes = matchRecipes(this.recipes, this.contextName);
|
|
63
59
|
|
|
64
|
-
|
|
60
|
+
debug('Recipes', recipes);
|
|
65
61
|
|
|
66
62
|
const currentOutputLevel = output.level();
|
|
67
63
|
output.level(0);
|
|
@@ -100,24 +96,24 @@ class Heal {
|
|
|
100
96
|
const suggestions = await this.getCodeSuggestions(failureContext);
|
|
101
97
|
|
|
102
98
|
if (suggestions.length === 0) {
|
|
103
|
-
|
|
99
|
+
debug('No healing suggestions found');
|
|
104
100
|
throw error;
|
|
105
101
|
}
|
|
106
102
|
|
|
107
103
|
output.debug(`Received ${suggestions.length} suggestion${suggestions.length === 1 ? '' : 's'}`);
|
|
108
104
|
|
|
109
|
-
|
|
105
|
+
debug(suggestions);
|
|
110
106
|
|
|
111
107
|
for (const suggestion of suggestions) {
|
|
112
108
|
for (const codeSnippet of suggestion.snippets) {
|
|
113
109
|
try {
|
|
114
|
-
|
|
110
|
+
debug('Executing', codeSnippet);
|
|
115
111
|
recorder.catch((e) => {
|
|
116
|
-
|
|
112
|
+
debug(e);
|
|
117
113
|
});
|
|
118
114
|
|
|
119
115
|
if (typeof codeSnippet === 'string') {
|
|
120
|
-
const I = Container.support('I');
|
|
116
|
+
const I = Container.support('I');
|
|
121
117
|
await eval(codeSnippet); // eslint-disable-line
|
|
122
118
|
} else if (typeof codeSnippet === 'function') {
|
|
123
119
|
await codeSnippet(Container.support());
|
|
@@ -135,7 +131,7 @@ class Heal {
|
|
|
135
131
|
// recorder.session.restore();
|
|
136
132
|
return;
|
|
137
133
|
} catch (err) {
|
|
138
|
-
|
|
134
|
+
debug('Failed to execute code', err);
|
|
139
135
|
recorder.ignoreErr(err); // healing did not help
|
|
140
136
|
recorder.catchWithoutStop(err);
|
|
141
137
|
await recorder.promise(); // wait for all promises to resolve
|
|
@@ -153,7 +149,7 @@ class Heal {
|
|
|
153
149
|
|
|
154
150
|
const heal = new Heal();
|
|
155
151
|
|
|
156
|
-
|
|
152
|
+
module.exports = heal;
|
|
157
153
|
|
|
158
154
|
function matchRecipes(recipes, contextName) {
|
|
159
155
|
return Object.entries(recipes)
|