codeceptjs 4.0.0-beta.1 → 4.0.0-beta.3
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/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 +57 -49
- package/lib/codecept.js +142 -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 +71 -68
- package/lib/command/generate.js +197 -188
- package/lib/command/gherkin/init.js +27 -16
- package/lib/command/gherkin/snippets.js +20 -20
- 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 +10 -10
- 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 +13 -17
- package/lib/helper/AI.js +130 -41
- package/lib/helper/ApiDataFactory.js +73 -69
- package/lib/helper/Appium.js +413 -382
- 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 +50 -50
- package/lib/helper/JSONResponse.js +65 -62
- package/lib/helper/Mochawesome.js +28 -28
- package/lib/helper/MockServer.js +12 -14
- package/lib/helper/Nightmare.js +662 -566
- package/lib/helper/Playwright.js +1361 -1216
- package/lib/helper/Protractor.js +663 -627
- package/lib/helper/Puppeteer.js +1231 -1128
- package/lib/helper/REST.js +159 -68
- package/lib/helper/SoftExpectHelper.js +2 -2
- package/lib/helper/TestCafe.js +490 -484
- package/lib/helper/WebDriver.js +1297 -1156
- 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 +2 -2
- 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 +3 -2
- 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 +6 -7
- 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 +6 -10
- package/lib/mochaFactory.js +18 -15
- package/lib/output.js +6 -10
- package/lib/parser.js +15 -12
- package/lib/pause.js +40 -33
- 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 +115 -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 -2
- 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 -32
- package/package.json +56 -57
- package/translations/de-DE.js +1 -1
- package/translations/fr-FR.js +1 -1
- 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 +415 -65
- package/typings/promiseBasedTypes.d.ts +32 -0
- package/typings/types.d.ts +32 -0
- package/lib/dirname.js +0 -5
- package/lib/helper/Expect.js +0 -425
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
const { getConfig, getTestRoot } = require('./utils')
|
|
2
|
+
const recorder = require('../recorder')
|
|
3
|
+
const Codecept = require('../codecept')
|
|
4
|
+
const Container = require('../container')
|
|
5
|
+
const event = require('../event')
|
|
6
|
+
const output = require('../output')
|
|
7
|
+
const webHelpers = require('../plugin/standardActingHelpers')
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
module.exports = async function (path, options) {
|
|
10
10
|
// Backward compatibility for --profile
|
|
11
|
-
process.profile = options.profile
|
|
12
|
-
process.env.profile = options.profile
|
|
13
|
-
const configFile = options.config
|
|
11
|
+
process.profile = options.profile
|
|
12
|
+
process.env.profile = options.profile
|
|
13
|
+
const configFile = options.config
|
|
14
14
|
|
|
15
|
-
const config = getConfig(configFile)
|
|
16
|
-
const testsPath = getTestRoot(configFile)
|
|
15
|
+
const config = getConfig(configFile)
|
|
16
|
+
const testsPath = getTestRoot(configFile)
|
|
17
17
|
|
|
18
|
-
const codecept = new Codecept(config, options)
|
|
19
|
-
codecept.init(testsPath)
|
|
18
|
+
const codecept = new Codecept(config, options)
|
|
19
|
+
codecept.init(testsPath)
|
|
20
20
|
|
|
21
21
|
try {
|
|
22
|
-
await codecept.bootstrap()
|
|
22
|
+
await codecept.bootstrap()
|
|
23
23
|
|
|
24
|
-
if (options.verbose) output.level(3)
|
|
24
|
+
if (options.verbose) output.level(3)
|
|
25
25
|
|
|
26
|
-
output.print('Starting interactive shell for current suite...')
|
|
27
|
-
recorder.start()
|
|
26
|
+
output.print('Starting interactive shell for current suite...')
|
|
27
|
+
recorder.start()
|
|
28
28
|
event.emit(event.suite.before, {
|
|
29
29
|
fullTitle: () => 'Interactive Shell',
|
|
30
30
|
tests: [],
|
|
31
|
-
})
|
|
31
|
+
})
|
|
32
32
|
event.emit(event.test.before, {
|
|
33
33
|
title: '',
|
|
34
34
|
artifacts: {},
|
|
35
|
-
})
|
|
35
|
+
})
|
|
36
36
|
|
|
37
|
-
const enabledHelpers = Container.helpers()
|
|
37
|
+
const enabledHelpers = Container.helpers()
|
|
38
38
|
for (const helperName of Object.keys(enabledHelpers)) {
|
|
39
39
|
if (webHelpers.includes(helperName)) {
|
|
40
|
-
const I = enabledHelpers[helperName]
|
|
41
|
-
recorder.add(() => I.amOnPage('/'))
|
|
42
|
-
recorder.catchWithoutStop(e => output.print(`Error while loading home page: ${e.message}}`))
|
|
43
|
-
break
|
|
40
|
+
const I = enabledHelpers[helperName]
|
|
41
|
+
recorder.add(() => I.amOnPage('/'))
|
|
42
|
+
recorder.catchWithoutStop((e) => output.print(`Error while loading home page: ${e.message}}`))
|
|
43
|
+
break
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
require('../pause')()
|
|
46
|
+
require('../pause')()
|
|
47
47
|
// recorder.catchWithoutStop((err) => console.log(err.stack));
|
|
48
|
-
recorder.add(() => event.emit(event.test.after, {}))
|
|
49
|
-
recorder.add(() => event.emit(event.suite.after, {}))
|
|
50
|
-
recorder.add(() => event.emit(event.all.result, {}))
|
|
51
|
-
recorder.add(() => codecept.teardown())
|
|
48
|
+
recorder.add(() => event.emit(event.test.after, {}))
|
|
49
|
+
recorder.add(() => event.emit(event.suite.after, {}))
|
|
50
|
+
recorder.add(() => event.emit(event.all.result, {}))
|
|
51
|
+
recorder.add(() => codecept.teardown())
|
|
52
52
|
} catch (err) {
|
|
53
|
-
output.
|
|
53
|
+
output.error(`Error while running bootstrap file :${err}`)
|
|
54
54
|
}
|
|
55
55
|
}
|
package/lib/command/list.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const { getConfig, getTestRoot } = require('./utils')
|
|
2
|
+
const Codecept = require('../codecept')
|
|
3
|
+
const container = require('../container')
|
|
4
|
+
const { getParamsToString } = require('../parser')
|
|
5
|
+
const { methodsOfObject } = require('../utils')
|
|
6
|
+
const output = require('../output')
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
const testsPath = getTestRoot(path)
|
|
10
|
-
const config = getConfig(testsPath)
|
|
11
|
-
const codecept = new Codecept(config, {})
|
|
12
|
-
codecept.init(testsPath)
|
|
8
|
+
module.exports = function (path) {
|
|
9
|
+
const testsPath = getTestRoot(path)
|
|
10
|
+
const config = getConfig(testsPath)
|
|
11
|
+
const codecept = new Codecept(config, {})
|
|
12
|
+
codecept.init(testsPath)
|
|
13
13
|
|
|
14
|
-
output.print('List of test actions: -- ')
|
|
15
|
-
const helpers = container.helpers()
|
|
16
|
-
const supportI = container.support('I')
|
|
17
|
-
const actions = []
|
|
14
|
+
output.print('List of test actions: -- ')
|
|
15
|
+
const helpers = container.helpers()
|
|
16
|
+
const supportI = container.support('I')
|
|
17
|
+
const actions = []
|
|
18
18
|
for (const name in helpers) {
|
|
19
|
-
const helper = helpers[name]
|
|
19
|
+
const helper = helpers[name]
|
|
20
20
|
methodsOfObject(helper).forEach((action) => {
|
|
21
|
-
const params = getParamsToString(helper[action])
|
|
22
|
-
actions[action] = 1
|
|
23
|
-
output.print(` ${output.
|
|
24
|
-
})
|
|
21
|
+
const params = getParamsToString(helper[action])
|
|
22
|
+
actions[action] = 1
|
|
23
|
+
output.print(` ${output.colors.grey(name)} I.${output.colors.bold(action)}(${params})`)
|
|
24
|
+
})
|
|
25
25
|
}
|
|
26
26
|
for (const name in supportI) {
|
|
27
27
|
if (actions[name]) {
|
|
28
|
-
continue
|
|
28
|
+
continue
|
|
29
29
|
}
|
|
30
|
-
const actor = supportI[name]
|
|
31
|
-
const params = getParamsToString(actor)
|
|
32
|
-
output.print(` I.${output.
|
|
30
|
+
const actor = supportI[name]
|
|
31
|
+
const params = getParamsToString(actor)
|
|
32
|
+
output.print(` I.${output.colors.bold(name)}(${params})`)
|
|
33
33
|
}
|
|
34
|
-
output.print('PS: Actions are retrieved from enabled helpers. ')
|
|
35
|
-
output.print('Implement custom actions in your helper classes.')
|
|
34
|
+
output.print('PS: Actions are retrieved from enabled helpers. ')
|
|
35
|
+
output.print('Implement custom actions in your helper classes.')
|
|
36
36
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const glob = require('glob');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const fs = require('fs');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Splits a list to (n) parts, defined via the size argument.
|
|
@@ -61,7 +61,7 @@ const mapFileFormats = (files) => {
|
|
|
61
61
|
* files by the passed number or executing a usder deifned function to perform
|
|
62
62
|
* the splitting.
|
|
63
63
|
*/
|
|
64
|
-
|
|
64
|
+
const createChunks = (config, patterns = []) => {
|
|
65
65
|
const files = patterns.filter(pattern => !!pattern).map((pattern) => {
|
|
66
66
|
return findFiles(pattern).filter((file) => {
|
|
67
67
|
return config.grep ? grepFile(file, config.grep) : true;
|
|
@@ -86,6 +86,6 @@ export const createChunks = (config, patterns = []) => {
|
|
|
86
86
|
});
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
module.exports = {
|
|
90
90
|
createChunks,
|
|
91
91
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const { createChunks } = require('./chunk');
|
|
2
|
+
const { createRun } = require('./run');
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Bootstraps a collection of runs, it combines user defined selection of runs
|
|
@@ -190,6 +190,6 @@ function guessBrowser(config) {
|
|
|
190
190
|
return [config.helpers[firstHelper].browser];
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
|
|
193
|
+
module.exports = {
|
|
194
194
|
createRuns,
|
|
195
195
|
};
|
|
@@ -1,186 +1,206 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
const { fork } = require('child_process')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
const crypto = require('crypto')
|
|
4
|
+
|
|
5
|
+
const runHook = require('../hooks')
|
|
6
|
+
const event = require('../event')
|
|
7
|
+
const collection = require('./run-multiple/collection')
|
|
8
|
+
const { clearString, replaceValueDeep } = require('../utils')
|
|
9
|
+
const { getConfig, getTestRoot, fail } = require('./utils')
|
|
10
|
+
|
|
11
|
+
const runner = path.join(__dirname, '/../../bin/codecept')
|
|
12
|
+
let config
|
|
13
|
+
const childOpts = {}
|
|
14
|
+
const copyOptions = [
|
|
15
|
+
'override',
|
|
16
|
+
'steps',
|
|
17
|
+
'reporter',
|
|
18
|
+
'verbose',
|
|
19
|
+
'config',
|
|
20
|
+
'reporter-options',
|
|
21
|
+
'grep',
|
|
22
|
+
'fgrep',
|
|
23
|
+
'invert',
|
|
24
|
+
'debug',
|
|
25
|
+
'plugins',
|
|
26
|
+
'colors',
|
|
27
|
+
]
|
|
28
|
+
let overrides = {}
|
|
18
29
|
|
|
19
30
|
// codeceptjs run-multiple smoke:chrome regression:firefox - will launch smoke run in chrome and regression in firefox
|
|
20
31
|
// codeceptjs run-multiple smoke:chrome regression - will launch smoke run in chrome and regression in firefox and chrome
|
|
21
32
|
// codeceptjs run-multiple --all - will launch all runs
|
|
22
33
|
// codeceptjs run-multiple smoke regression'
|
|
23
34
|
|
|
24
|
-
let runId = 1
|
|
25
|
-
let subprocessCount = 0
|
|
26
|
-
let totalSubprocessCount = 0
|
|
27
|
-
let processesDone
|
|
35
|
+
let runId = 1
|
|
36
|
+
let subprocessCount = 0
|
|
37
|
+
let totalSubprocessCount = 0
|
|
38
|
+
let processesDone
|
|
28
39
|
|
|
29
|
-
|
|
40
|
+
module.exports = async function (selectedRuns, options) {
|
|
30
41
|
// registering options globally to use in config
|
|
31
42
|
if (options.profile) {
|
|
32
|
-
process.env.profile = options.profile
|
|
43
|
+
process.env.profile = options.profile
|
|
33
44
|
}
|
|
34
|
-
const configFile = options.config
|
|
45
|
+
const configFile = options.config
|
|
35
46
|
|
|
36
|
-
const testRoot = getTestRoot(configFile)
|
|
37
|
-
global.codecept_dir = testRoot
|
|
47
|
+
const testRoot = getTestRoot(configFile)
|
|
48
|
+
global.codecept_dir = testRoot
|
|
38
49
|
|
|
39
50
|
// copy opts to run
|
|
40
51
|
Object.keys(options)
|
|
41
|
-
.filter(key => copyOptions.indexOf(key) > -1)
|
|
52
|
+
.filter((key) => copyOptions.indexOf(key) > -1)
|
|
42
53
|
.forEach((key) => {
|
|
43
|
-
childOpts[key] = options[key]
|
|
44
|
-
})
|
|
54
|
+
childOpts[key] = options[key]
|
|
55
|
+
})
|
|
45
56
|
|
|
46
57
|
try {
|
|
47
|
-
overrides = JSON.parse(childOpts.override)
|
|
48
|
-
delete childOpts.override
|
|
58
|
+
overrides = JSON.parse(childOpts.override)
|
|
59
|
+
delete childOpts.override
|
|
49
60
|
} catch (e) {
|
|
50
|
-
overrides = {}
|
|
61
|
+
overrides = {}
|
|
51
62
|
}
|
|
52
63
|
|
|
53
64
|
config = {
|
|
54
65
|
...getConfig(configFile),
|
|
55
66
|
...overrides,
|
|
56
|
-
}
|
|
67
|
+
}
|
|
57
68
|
|
|
58
69
|
if (!config.multiple) {
|
|
59
|
-
fail('Multiple runs not configured, add "multiple": { /../ } section to config')
|
|
70
|
+
fail('Multiple runs not configured, add "multiple": { /../ } section to config')
|
|
60
71
|
}
|
|
61
72
|
|
|
62
|
-
selectedRuns = options.all ? Object.keys(config.multiple) : selectedRuns
|
|
73
|
+
selectedRuns = options.all ? Object.keys(config.multiple) : selectedRuns
|
|
63
74
|
if (!selectedRuns.length) {
|
|
64
|
-
fail('No runs provided. Use --all option to run all configured runs')
|
|
75
|
+
fail('No runs provided. Use --all option to run all configured runs')
|
|
65
76
|
}
|
|
66
77
|
|
|
67
|
-
await runHook(config.bootstrapAll, 'bootstrapAll')
|
|
78
|
+
await runHook(config.bootstrapAll, 'bootstrapAll')
|
|
68
79
|
|
|
69
|
-
event.emit(event.multiple.before, null)
|
|
70
|
-
if (options.config) {
|
|
80
|
+
event.emit(event.multiple.before, null)
|
|
81
|
+
if (options.config) {
|
|
82
|
+
// update paths to config path
|
|
71
83
|
if (config.tests) {
|
|
72
|
-
config.tests = path.resolve(testRoot, config.tests)
|
|
84
|
+
config.tests = path.resolve(testRoot, config.tests)
|
|
73
85
|
}
|
|
74
86
|
if (config.gherkin && config.gherkin.features) {
|
|
75
|
-
config.gherkin.features = path.resolve(testRoot, config.gherkin.features)
|
|
87
|
+
config.gherkin.features = path.resolve(testRoot, config.gherkin.features)
|
|
76
88
|
}
|
|
77
89
|
}
|
|
78
90
|
|
|
79
91
|
if (options.features) {
|
|
80
|
-
config.tests = ''
|
|
92
|
+
config.tests = ''
|
|
81
93
|
}
|
|
82
94
|
|
|
83
95
|
if (options.tests && config.gherkin) {
|
|
84
|
-
config.gherkin.features = ''
|
|
96
|
+
config.gherkin.features = ''
|
|
85
97
|
}
|
|
86
98
|
|
|
87
99
|
const childProcessesPromise = new Promise((resolve) => {
|
|
88
|
-
processesDone = resolve
|
|
89
|
-
})
|
|
100
|
+
processesDone = resolve
|
|
101
|
+
})
|
|
90
102
|
|
|
91
|
-
const runsToExecute = []
|
|
103
|
+
const runsToExecute = []
|
|
92
104
|
collection.createRuns(selectedRuns, config).forEach((run) => {
|
|
93
|
-
const runName = run.getOriginalName() || run.getName()
|
|
94
|
-
const runConfig = run.getConfig()
|
|
95
|
-
runsToExecute.push(executeRun(runName, runConfig))
|
|
96
|
-
})
|
|
105
|
+
const runName = run.getOriginalName() || run.getName()
|
|
106
|
+
const runConfig = run.getConfig()
|
|
107
|
+
runsToExecute.push(executeRun(runName, runConfig))
|
|
108
|
+
})
|
|
97
109
|
|
|
98
110
|
if (!runsToExecute.length) {
|
|
99
|
-
fail('Nothing scheduled for execution')
|
|
111
|
+
fail('Nothing scheduled for execution')
|
|
100
112
|
}
|
|
101
113
|
|
|
102
114
|
// Execute all forks
|
|
103
|
-
totalSubprocessCount = runsToExecute.length
|
|
104
|
-
runsToExecute.forEach(runToExecute => runToExecute.call(this))
|
|
115
|
+
totalSubprocessCount = runsToExecute.length
|
|
116
|
+
runsToExecute.forEach((runToExecute) => runToExecute.call(this))
|
|
105
117
|
|
|
106
118
|
return childProcessesPromise.then(async () => {
|
|
107
119
|
// fire hook
|
|
108
|
-
await runHook(config.teardownAll, 'teardownAll')
|
|
109
|
-
event.emit(event.multiple.after, null)
|
|
110
|
-
})
|
|
120
|
+
await runHook(config.teardownAll, 'teardownAll')
|
|
121
|
+
event.emit(event.multiple.after, null)
|
|
122
|
+
})
|
|
111
123
|
}
|
|
112
124
|
|
|
113
125
|
function executeRun(runName, runConfig) {
|
|
114
126
|
// clone config
|
|
115
|
-
let overriddenConfig = { ...config }
|
|
127
|
+
let overriddenConfig = { ...config }
|
|
116
128
|
|
|
117
129
|
// get configuration
|
|
118
|
-
const browserConfig = runConfig.browser
|
|
119
|
-
const browserName = browserConfig.browser
|
|
130
|
+
const browserConfig = runConfig.browser
|
|
131
|
+
const browserName = browserConfig.browser
|
|
120
132
|
|
|
121
133
|
for (const key in browserConfig) {
|
|
122
|
-
overriddenConfig.helpers = replaceValueDeep(overriddenConfig.helpers, key, browserConfig[key])
|
|
134
|
+
overriddenConfig.helpers = replaceValueDeep(overriddenConfig.helpers, key, browserConfig[key])
|
|
123
135
|
}
|
|
124
136
|
|
|
125
|
-
let outputDir = `${runName}_
|
|
137
|
+
let outputDir = `${runName}_`
|
|
126
138
|
if (browserConfig.outputName) {
|
|
127
|
-
outputDir += typeof browserConfig.outputName === 'function' ? browserConfig.outputName() : browserConfig.outputName
|
|
139
|
+
outputDir += typeof browserConfig.outputName === 'function' ? browserConfig.outputName() : browserConfig.outputName
|
|
128
140
|
} else {
|
|
129
|
-
const hash = crypto.createHash('sha256')
|
|
130
|
-
hash.update(JSON.stringify(browserConfig))
|
|
131
|
-
outputDir += hash.digest('hex')
|
|
141
|
+
const hash = crypto.createHash('sha256')
|
|
142
|
+
hash.update(JSON.stringify(browserConfig))
|
|
143
|
+
outputDir += hash.digest('hex')
|
|
132
144
|
}
|
|
133
|
-
outputDir += `_${runId}
|
|
145
|
+
outputDir += `_${runId}`
|
|
134
146
|
|
|
135
|
-
outputDir = clearString(outputDir)
|
|
147
|
+
outputDir = clearString(outputDir)
|
|
136
148
|
|
|
137
149
|
// tweaking default output directories and for mochawesome
|
|
138
|
-
overriddenConfig = replaceValueDeep(overriddenConfig, 'output', path.join(config.output, outputDir))
|
|
139
|
-
overriddenConfig = replaceValueDeep(overriddenConfig, 'reportDir', path.join(config.output, outputDir))
|
|
140
|
-
overriddenConfig = replaceValueDeep(
|
|
150
|
+
overriddenConfig = replaceValueDeep(overriddenConfig, 'output', path.join(config.output, outputDir))
|
|
151
|
+
overriddenConfig = replaceValueDeep(overriddenConfig, 'reportDir', path.join(config.output, outputDir))
|
|
152
|
+
overriddenConfig = replaceValueDeep(
|
|
153
|
+
overriddenConfig,
|
|
154
|
+
'mochaFile',
|
|
155
|
+
path.join(config.output, outputDir, `${browserName}_report.xml`),
|
|
156
|
+
)
|
|
141
157
|
|
|
142
158
|
// override tests configuration
|
|
143
159
|
if (overriddenConfig.tests) {
|
|
144
|
-
overriddenConfig.tests = runConfig.tests
|
|
160
|
+
overriddenConfig.tests = runConfig.tests
|
|
145
161
|
}
|
|
146
162
|
|
|
147
163
|
if (overriddenConfig.gherkin && runConfig.gherkin && runConfig.gherkin.features) {
|
|
148
|
-
overriddenConfig.gherkin.features = runConfig.gherkin.features
|
|
164
|
+
overriddenConfig.gherkin.features = runConfig.gherkin.features
|
|
149
165
|
}
|
|
150
166
|
|
|
151
167
|
// override grep param and collect all params
|
|
152
|
-
const params = [
|
|
153
|
-
'
|
|
154
|
-
'--
|
|
155
|
-
|
|
168
|
+
const params = [
|
|
169
|
+
'run',
|
|
170
|
+
'--child',
|
|
171
|
+
`${runId++}.${runName}:${browserName}`,
|
|
172
|
+
'--override',
|
|
173
|
+
JSON.stringify(overriddenConfig),
|
|
174
|
+
]
|
|
156
175
|
|
|
157
176
|
Object.keys(childOpts).forEach((key) => {
|
|
158
|
-
params.push(`--${key}`)
|
|
159
|
-
if (childOpts[key] !== true) params.push(childOpts[key])
|
|
160
|
-
})
|
|
177
|
+
params.push(`--${key}`)
|
|
178
|
+
if (childOpts[key] !== true) params.push(childOpts[key])
|
|
179
|
+
})
|
|
161
180
|
|
|
162
181
|
if (runConfig.grep) {
|
|
163
|
-
params.push('--grep')
|
|
164
|
-
params.push(runConfig.grep)
|
|
182
|
+
params.push('--grep')
|
|
183
|
+
params.push(runConfig.grep)
|
|
165
184
|
}
|
|
166
185
|
|
|
167
186
|
const onProcessEnd = (errorCode) => {
|
|
168
187
|
if (errorCode !== 0) {
|
|
169
|
-
process.exitCode = errorCode
|
|
188
|
+
process.exitCode = errorCode
|
|
170
189
|
}
|
|
171
|
-
subprocessCount += 1
|
|
190
|
+
subprocessCount += 1
|
|
172
191
|
if (subprocessCount === totalSubprocessCount) {
|
|
173
|
-
processesDone()
|
|
192
|
+
processesDone()
|
|
174
193
|
}
|
|
175
|
-
return errorCode
|
|
176
|
-
}
|
|
194
|
+
return errorCode
|
|
195
|
+
}
|
|
177
196
|
|
|
178
197
|
// Return function of fork for later execution
|
|
179
|
-
return () =>
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
198
|
+
return () =>
|
|
199
|
+
fork(runner, params, { stdio: [0, 1, 2, 'ipc'] })
|
|
200
|
+
.on('exit', (code) => {
|
|
201
|
+
return onProcessEnd(code)
|
|
202
|
+
})
|
|
203
|
+
.on('error', () => {
|
|
204
|
+
return onProcessEnd(1)
|
|
205
|
+
})
|
|
186
206
|
}
|
package/lib/command/run-rerun.js
CHANGED
|
@@ -1,39 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import Codecept from '../rerun.js';
|
|
1
|
+
const { getConfig, getTestRoot } = require('./utils')
|
|
2
|
+
const { printError, createOutputDir } = require('./utils')
|
|
3
|
+
const Config = require('../config')
|
|
4
|
+
const Codecept = require('../rerun')
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
module.exports = async function (test, options) {
|
|
8
7
|
// registering options globally to use in config
|
|
9
8
|
// Backward compatibility for --profile
|
|
10
|
-
process.profile = options.profile
|
|
11
|
-
process.env.profile = options.profile
|
|
12
|
-
const configFile = options.config
|
|
9
|
+
process.profile = options.profile
|
|
10
|
+
process.env.profile = options.profile
|
|
11
|
+
const configFile = options.config
|
|
13
12
|
|
|
14
|
-
let config = getConfig(configFile)
|
|
13
|
+
let config = getConfig(configFile)
|
|
15
14
|
if (options.override) {
|
|
16
|
-
config = Config.append(JSON.parse(options.override))
|
|
15
|
+
config = Config.append(JSON.parse(options.override))
|
|
17
16
|
}
|
|
18
|
-
const testRoot = getTestRoot(configFile)
|
|
19
|
-
createOutputDir(config, testRoot)
|
|
17
|
+
const testRoot = getTestRoot(configFile)
|
|
18
|
+
createOutputDir(config, testRoot)
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
printError(err);
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
const codecept = new Codecept(config, options);
|
|
20
|
+
const codecept = new Codecept(config, options)
|
|
26
21
|
|
|
27
22
|
try {
|
|
28
|
-
codecept.init(testRoot)
|
|
23
|
+
codecept.init(testRoot)
|
|
29
24
|
|
|
30
|
-
await codecept.bootstrap()
|
|
31
|
-
codecept.loadTests(test)
|
|
32
|
-
await codecept.run()
|
|
25
|
+
await codecept.bootstrap()
|
|
26
|
+
codecept.loadTests(test)
|
|
27
|
+
await codecept.run()
|
|
33
28
|
} catch (err) {
|
|
34
|
-
printError(err)
|
|
35
|
-
process.exitCode = 1
|
|
29
|
+
printError(err)
|
|
30
|
+
process.exitCode = 1
|
|
36
31
|
} finally {
|
|
37
|
-
await codecept.teardown()
|
|
32
|
+
await codecept.teardown()
|
|
38
33
|
}
|
|
39
34
|
}
|