codeceptjs 3.6.10 → 3.7.0-beta.1
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 +81 -110
- package/bin/codecept.js +2 -2
- package/docs/webapi/clearCookie.mustache +1 -1
- package/lib/actor.js +46 -36
- package/lib/assert/empty.js +3 -5
- package/lib/assert/equal.js +4 -7
- package/lib/assert/include.js +4 -6
- package/lib/assert/throws.js +2 -4
- package/lib/assert/truth.js +2 -2
- package/lib/codecept.js +87 -83
- package/lib/command/configMigrate.js +2 -4
- package/lib/command/definitions.js +5 -25
- package/lib/command/generate.js +10 -14
- package/lib/command/gherkin/snippets.js +10 -8
- package/lib/command/gherkin/steps.js +1 -1
- package/lib/command/info.js +1 -3
- package/lib/command/init.js +8 -12
- package/lib/command/interactive.js +1 -1
- package/lib/command/list.js +1 -1
- package/lib/command/run-multiple.js +12 -35
- package/lib/command/run-workers.js +10 -10
- package/lib/command/utils.js +5 -6
- package/lib/command/workers/runTests.js +14 -17
- package/lib/container.js +327 -237
- package/lib/data/context.js +10 -13
- package/lib/data/dataScenarioConfig.js +8 -8
- package/lib/data/dataTableArgument.js +6 -6
- package/lib/data/table.js +5 -11
- package/lib/els.js +177 -0
- package/lib/event.js +1 -0
- package/lib/heal.js +78 -80
- package/lib/helper/ApiDataFactory.js +3 -6
- package/lib/helper/Appium.js +15 -30
- package/lib/helper/FileSystem.js +3 -3
- package/lib/helper/GraphQLDataFactory.js +3 -3
- package/lib/helper/JSONResponse.js +57 -37
- package/lib/helper/Nightmare.js +35 -53
- package/lib/helper/Playwright.js +189 -251
- package/lib/helper/Protractor.js +54 -77
- package/lib/helper/Puppeteer.js +134 -232
- package/lib/helper/REST.js +5 -17
- package/lib/helper/TestCafe.js +21 -44
- package/lib/helper/WebDriver.js +103 -162
- package/lib/helper/testcafe/testcafe-utils.js +26 -27
- package/lib/listener/artifacts.js +2 -2
- package/lib/listener/emptyRun.js +58 -0
- package/lib/listener/exit.js +4 -4
- package/lib/listener/{retry.js → globalRetry.js} +5 -5
- package/lib/listener/{timeout.js → globalTimeout.js} +8 -8
- package/lib/listener/helpers.js +15 -15
- package/lib/listener/mocha.js +1 -1
- package/lib/listener/steps.js +17 -12
- package/lib/listener/store.js +12 -0
- package/lib/mocha/asyncWrapper.js +204 -0
- package/lib/{interfaces → mocha}/bdd.js +3 -3
- package/lib/mocha/cli.js +257 -0
- package/lib/mocha/factory.js +104 -0
- package/lib/{interfaces → mocha}/featureConfig.js +11 -12
- package/lib/{interfaces → mocha}/gherkin.js +26 -28
- package/lib/mocha/hooks.js +83 -0
- package/lib/mocha/index.js +12 -0
- package/lib/mocha/inject.js +24 -0
- package/lib/{interfaces → mocha}/scenarioConfig.js +10 -6
- package/lib/mocha/suite.js +55 -0
- package/lib/mocha/test.js +60 -0
- package/lib/mocha/types.d.ts +31 -0
- package/lib/mocha/ui.js +219 -0
- package/lib/output.js +28 -10
- package/lib/pause.js +159 -135
- package/lib/plugin/autoDelay.js +4 -4
- package/lib/plugin/autoLogin.js +6 -7
- package/lib/plugin/commentStep.js +1 -1
- package/lib/plugin/coverage.js +10 -19
- package/lib/plugin/customLocator.js +3 -3
- package/lib/plugin/debugErrors.js +2 -2
- package/lib/plugin/eachElement.js +1 -1
- package/lib/plugin/fakerTransform.js +1 -1
- package/lib/plugin/heal.js +6 -9
- package/lib/plugin/retryFailedStep.js +4 -4
- package/lib/plugin/retryTo.js +2 -2
- package/lib/plugin/screenshotOnFail.js +9 -36
- package/lib/plugin/selenoid.js +15 -35
- package/lib/plugin/stepByStepReport.js +51 -13
- package/lib/plugin/stepTimeout.js +4 -11
- package/lib/plugin/subtitles.js +4 -4
- package/lib/plugin/tryTo.js +1 -1
- package/lib/plugin/wdio.js +8 -10
- package/lib/recorder.js +142 -121
- package/lib/secret.js +1 -1
- package/lib/step.js +160 -144
- package/lib/store.js +6 -2
- package/lib/template/heal.js +2 -11
- package/lib/utils.js +224 -216
- package/lib/within.js +73 -55
- package/lib/workers.js +265 -261
- package/package.json +46 -47
- package/typings/index.d.ts +172 -184
- package/typings/promiseBasedTypes.d.ts +53 -516
- package/typings/types.d.ts +127 -587
- package/lib/cli.js +0 -256
- package/lib/helper/ExpectHelper.js +0 -391
- package/lib/helper/SoftExpectHelper.js +0 -381
- package/lib/mochaFactory.js +0 -113
- package/lib/scenario.js +0 -224
- package/lib/ui.js +0 -236
package/lib/within.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const output = require('./output')
|
|
2
|
-
const store = require('./store')
|
|
3
|
-
const recorder = require('./recorder')
|
|
4
|
-
const container = require('./container')
|
|
5
|
-
const event = require('./event')
|
|
6
|
-
const Step = require('./step')
|
|
7
|
-
const { isAsyncFunction } = require('./utils')
|
|
1
|
+
const output = require('./output')
|
|
2
|
+
const store = require('./store')
|
|
3
|
+
const recorder = require('./recorder')
|
|
4
|
+
const container = require('./container')
|
|
5
|
+
const event = require('./event')
|
|
6
|
+
const Step = require('./step')
|
|
7
|
+
const { isAsyncFunction } = require('./utils')
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @param {CodeceptJS.LocatorOrString} context
|
|
@@ -12,59 +12,77 @@ const { isAsyncFunction } = require('./utils');
|
|
|
12
12
|
* @return {Promise<*> | undefined}
|
|
13
13
|
*/
|
|
14
14
|
function within(context, fn) {
|
|
15
|
-
const helpers = store.dryRun ? {} : container.helpers()
|
|
16
|
-
const locator = typeof context === 'object' ? JSON.stringify(context) : context
|
|
15
|
+
const helpers = store.dryRun ? {} : container.helpers()
|
|
16
|
+
const locator = typeof context === 'object' ? JSON.stringify(context) : context
|
|
17
17
|
|
|
18
|
-
return recorder.add(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
return recorder.add(
|
|
19
|
+
'register within wrapper',
|
|
20
|
+
() => {
|
|
21
|
+
const metaStep = new WithinStep(locator, fn)
|
|
22
|
+
const defineMetaStep = step => (step.metaStep = metaStep)
|
|
23
|
+
recorder.session.start('within')
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
event.dispatcher.prependListener(event.step.before, defineMetaStep)
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
Object.keys(helpers).forEach(helper => {
|
|
28
|
+
if (helpers[helper]._withinBegin) recorder.add(`[${helper}] start within`, () => helpers[helper]._withinBegin(context))
|
|
29
|
+
})
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
const finalize = () => {
|
|
32
|
+
event.dispatcher.removeListener(event.step.before, defineMetaStep)
|
|
33
|
+
recorder.add('Finalize session within session', () => {
|
|
34
|
+
output.stepShift = 1
|
|
35
|
+
recorder.session.restore('within')
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
const finishHelpers = () => {
|
|
39
|
+
Object.keys(helpers).forEach(helper => {
|
|
40
|
+
if (helpers[helper]._withinEnd) recorder.add(`[${helper}] finish within`, () => helpers[helper]._withinEnd())
|
|
41
|
+
})
|
|
42
|
+
}
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
if (isAsyncFunction(fn)) {
|
|
45
|
+
return fn()
|
|
46
|
+
.then(res => {
|
|
47
|
+
finishHelpers()
|
|
48
|
+
finalize()
|
|
49
|
+
return recorder.promise().then(() => res)
|
|
50
|
+
})
|
|
51
|
+
.catch(e => {
|
|
52
|
+
finalize()
|
|
53
|
+
recorder.throw(e)
|
|
54
|
+
})
|
|
55
|
+
}
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
let res
|
|
58
|
+
try {
|
|
59
|
+
res = fn()
|
|
60
|
+
} catch (err) {
|
|
61
|
+
recorder.throw(err)
|
|
62
|
+
} finally {
|
|
63
|
+
finishHelpers()
|
|
64
|
+
recorder.catch(err => {
|
|
65
|
+
output.stepShift = 1
|
|
66
|
+
throw err
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
finalize()
|
|
70
|
+
return recorder.promise().then(() => res)
|
|
71
|
+
},
|
|
72
|
+
false,
|
|
73
|
+
false,
|
|
74
|
+
)
|
|
68
75
|
}
|
|
69
76
|
|
|
70
|
-
module.exports = within
|
|
77
|
+
module.exports = within
|
|
78
|
+
|
|
79
|
+
class WithinStep extends Step.MetaStep {
|
|
80
|
+
constructor(locator, fn) {
|
|
81
|
+
super('Within')
|
|
82
|
+
this.args = [locator]
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
toString() {
|
|
86
|
+
return `${this.prefix}Within ${this.humanizeArgs()}${this.suffix}`
|
|
87
|
+
}
|
|
88
|
+
}
|