codeceptjs 3.6.10 → 3.7.0-beta.10
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 +89 -119
- package/bin/codecept.js +9 -2
- package/docs/webapi/clearCookie.mustache +1 -1
- package/lib/actor.js +66 -102
- package/lib/ai.js +130 -121
- 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/check.js +186 -0
- package/lib/command/configMigrate.js +2 -4
- package/lib/command/definitions.js +8 -26
- 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 +2 -2
- package/lib/command/list.js +1 -1
- package/lib/command/run-multiple.js +12 -35
- package/lib/command/run-workers.js +5 -57
- package/lib/command/utils.js +5 -6
- package/lib/command/workers/runTests.js +68 -232
- package/lib/container.js +354 -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/effects.js +218 -0
- package/lib/els.js +158 -0
- package/lib/event.js +19 -17
- package/lib/heal.js +88 -80
- package/lib/helper/AI.js +2 -1
- package/lib/helper/ApiDataFactory.js +3 -6
- package/lib/helper/Appium.js +45 -51
- 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 +211 -252
- package/lib/helper/Protractor.js +54 -77
- package/lib/helper/Puppeteer.js +139 -232
- package/lib/helper/REST.js +5 -17
- package/lib/helper/TestCafe.js +21 -44
- package/lib/helper/WebDriver.js +131 -169
- package/lib/helper/testcafe/testcafe-utils.js +26 -27
- package/lib/listener/emptyRun.js +55 -0
- package/lib/listener/exit.js +7 -10
- package/lib/listener/{retry.js → globalRetry.js} +5 -5
- package/lib/listener/globalTimeout.js +165 -0
- package/lib/listener/helpers.js +15 -15
- package/lib/listener/mocha.js +1 -1
- package/lib/listener/result.js +12 -0
- package/lib/listener/steps.js +20 -18
- package/lib/listener/store.js +20 -0
- package/lib/mocha/asyncWrapper.js +216 -0
- package/lib/{interfaces → mocha}/bdd.js +3 -3
- package/lib/mocha/cli.js +308 -0
- package/lib/mocha/factory.js +104 -0
- package/lib/{interfaces → mocha}/featureConfig.js +24 -12
- package/lib/{interfaces → mocha}/gherkin.js +26 -28
- package/lib/mocha/hooks.js +112 -0
- package/lib/mocha/index.js +12 -0
- package/lib/mocha/inject.js +29 -0
- package/lib/{interfaces → mocha}/scenarioConfig.js +21 -6
- package/lib/mocha/suite.js +81 -0
- package/lib/mocha/test.js +159 -0
- package/lib/mocha/types.d.ts +42 -0
- package/lib/mocha/ui.js +219 -0
- package/lib/output.js +82 -62
- package/lib/pause.js +155 -138
- package/lib/plugin/analyze.js +349 -0
- package/lib/plugin/autoDelay.js +6 -6
- package/lib/plugin/autoLogin.js +6 -7
- package/lib/plugin/commentStep.js +6 -1
- package/lib/plugin/coverage.js +10 -19
- package/lib/plugin/customLocator.js +3 -3
- package/lib/plugin/customReporter.js +52 -0
- package/lib/plugin/eachElement.js +1 -1
- package/lib/plugin/fakerTransform.js +1 -1
- package/lib/plugin/heal.js +36 -9
- package/lib/plugin/pageInfo.js +140 -0
- package/lib/plugin/retryFailedStep.js +4 -4
- package/lib/plugin/retryTo.js +18 -118
- package/lib/plugin/screenshotOnFail.js +17 -49
- package/lib/plugin/selenoid.js +15 -35
- package/lib/plugin/standardActingHelpers.js +4 -1
- package/lib/plugin/stepByStepReport.js +56 -17
- package/lib/plugin/stepTimeout.js +5 -12
- package/lib/plugin/subtitles.js +4 -4
- package/lib/plugin/tryTo.js +17 -107
- package/lib/plugin/wdio.js +8 -10
- package/lib/recorder.js +146 -125
- package/lib/rerun.js +43 -42
- package/lib/result.js +161 -0
- package/lib/secret.js +1 -1
- package/lib/step/base.js +228 -0
- package/lib/step/config.js +50 -0
- package/lib/step/func.js +46 -0
- package/lib/step/helper.js +50 -0
- package/lib/step/meta.js +99 -0
- package/lib/step/record.js +74 -0
- package/lib/step/retry.js +11 -0
- package/lib/step/section.js +55 -0
- package/lib/step.js +21 -332
- package/lib/steps.js +50 -0
- package/lib/store.js +10 -2
- package/lib/template/heal.js +2 -11
- package/lib/timeout.js +66 -0
- package/lib/utils.js +317 -216
- package/lib/within.js +73 -55
- package/lib/workers.js +259 -275
- package/package.json +56 -54
- package/typings/index.d.ts +175 -186
- package/typings/promiseBasedTypes.d.ts +164 -17
- package/typings/types.d.ts +284 -115
- package/lib/cli.js +0 -256
- package/lib/helper/ExpectHelper.js +0 -391
- package/lib/helper/SoftExpectHelper.js +0 -381
- package/lib/listener/artifacts.js +0 -19
- package/lib/listener/timeout.js +0 -109
- package/lib/mochaFactory.js +0 -113
- package/lib/plugin/debugErrors.js +0 -67
- package/lib/scenario.js +0 -224
- package/lib/ui.js +0 -236
|
@@ -8,7 +8,7 @@ const fsPath = require('path');
|
|
|
8
8
|
const { getConfig, getTestRoot } = require('../utils');
|
|
9
9
|
const Codecept = require('../../codecept');
|
|
10
10
|
const output = require('../../output');
|
|
11
|
-
const { matchStep } = require('../../
|
|
11
|
+
const { matchStep } = require('../../mocha/bdd');
|
|
12
12
|
|
|
13
13
|
const uuidFn = Messages.IdGenerator.uuid();
|
|
14
14
|
const builder = new Gherkin.AstBuilder(uuidFn);
|
|
@@ -43,7 +43,7 @@ module.exports = function (genPath, options) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
const files = [];
|
|
46
|
-
glob.sync(options.feature || config.gherkin.features, { cwd: options.feature ? '.' : global.codecept_dir }).forEach(
|
|
46
|
+
glob.sync(options.feature || config.gherkin.features, { cwd: options.feature ? '.' : global.codecept_dir }).forEach(file => {
|
|
47
47
|
if (!fsPath.isAbsolute(file)) {
|
|
48
48
|
file = fsPath.join(global.codecept_dir, file);
|
|
49
49
|
}
|
|
@@ -53,7 +53,7 @@ module.exports = function (genPath, options) {
|
|
|
53
53
|
|
|
54
54
|
const newSteps = new Map();
|
|
55
55
|
|
|
56
|
-
const parseSteps =
|
|
56
|
+
const parseSteps = steps => {
|
|
57
57
|
const newSteps = [];
|
|
58
58
|
let currentKeyword = '';
|
|
59
59
|
for (const step of steps) {
|
|
@@ -86,13 +86,15 @@ module.exports = function (genPath, options) {
|
|
|
86
86
|
return newSteps;
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
const parseFile =
|
|
89
|
+
const parseFile = file => {
|
|
90
90
|
const ast = parser.parse(fs.readFileSync(file).toString());
|
|
91
91
|
for (const child of ast.feature.children) {
|
|
92
92
|
if (child.scenario.keyword === 'Scenario Outline') continue; // skip scenario outline
|
|
93
|
-
parseSteps(child.scenario.steps)
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
parseSteps(child.scenario.steps)
|
|
94
|
+
.map(step => {
|
|
95
|
+
return Object.assign(step, { file: file.replace(global.codecept_dir, '').slice(1) });
|
|
96
|
+
})
|
|
97
|
+
.map(step => newSteps.set(`${step.type}(${step})`, step));
|
|
96
98
|
}
|
|
97
99
|
};
|
|
98
100
|
|
|
@@ -110,7 +112,7 @@ module.exports = function (genPath, options) {
|
|
|
110
112
|
|
|
111
113
|
const snippets = [...newSteps.values()]
|
|
112
114
|
.filter((value, index, self) => self.indexOf(value) === index)
|
|
113
|
-
.map(
|
|
115
|
+
.map(step => {
|
|
114
116
|
return `
|
|
115
117
|
${step.type}(${step.regexp ? '/^' : "'"}${step}${step.regexp ? '$/' : "'"}, () => {
|
|
116
118
|
// From "${step.file}" ${JSON.stringify(step.location)}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { getConfig, getTestRoot } = require('../utils');
|
|
2
2
|
const Codecept = require('../../codecept');
|
|
3
3
|
const output = require('../../output');
|
|
4
|
-
const { getSteps } = require('../../
|
|
4
|
+
const { getSteps } = require('../../mocha/bdd');
|
|
5
5
|
|
|
6
6
|
module.exports = function (genPath, options) {
|
|
7
7
|
const configFile = options.config || genPath;
|
package/lib/command/info.js
CHANGED
|
@@ -34,9 +34,7 @@ module.exports = async function (path) {
|
|
|
34
34
|
output.print('***************************************')
|
|
35
35
|
output.print('If you have questions ask them in our Slack: http://bit.ly/chat-codeceptjs')
|
|
36
36
|
output.print('Or ask them on our discussion board: https://codecept.discourse.group/')
|
|
37
|
-
output.print(
|
|
38
|
-
'Please copy environment info when you report issues on GitHub: https://github.com/Codeception/CodeceptJS/issues',
|
|
39
|
-
)
|
|
37
|
+
output.print('Please copy environment info when you report issues on GitHub: https://github.com/Codeception/CodeceptJS/issues')
|
|
40
38
|
output.print('***************************************')
|
|
41
39
|
}
|
|
42
40
|
|
package/lib/command/init.js
CHANGED
|
@@ -117,7 +117,7 @@ module.exports = function (initPath) {
|
|
|
117
117
|
{
|
|
118
118
|
name: 'tests',
|
|
119
119
|
type: 'input',
|
|
120
|
-
default:
|
|
120
|
+
default: answers => `./*_test.${answers.typescript ? 'ts' : 'js'}`,
|
|
121
121
|
message: 'Where are your tests located?',
|
|
122
122
|
},
|
|
123
123
|
{
|
|
@@ -132,7 +132,7 @@ module.exports = function (initPath) {
|
|
|
132
132
|
type: 'confirm',
|
|
133
133
|
default: true,
|
|
134
134
|
message: 'Do you want to use JSONResponse helper for assertions on JSON responses? http://bit.ly/3ASVPy9',
|
|
135
|
-
when:
|
|
135
|
+
when: answers => ['GraphQL', 'REST'].includes(answers.helper) === true,
|
|
136
136
|
},
|
|
137
137
|
{
|
|
138
138
|
name: 'output',
|
|
@@ -146,7 +146,7 @@ module.exports = function (initPath) {
|
|
|
146
146
|
choices: translations,
|
|
147
147
|
},
|
|
148
148
|
])
|
|
149
|
-
.then(
|
|
149
|
+
.then(result => {
|
|
150
150
|
if (result.typescript === true) {
|
|
151
151
|
isTypeScript = true
|
|
152
152
|
extension = isTypeScript === true ? 'ts' : 'js'
|
|
@@ -189,7 +189,7 @@ module.exports = function (initPath) {
|
|
|
189
189
|
|
|
190
190
|
if (!Helper._config()) return
|
|
191
191
|
helperConfigs = helperConfigs.concat(
|
|
192
|
-
Helper._config().map(
|
|
192
|
+
Helper._config().map(config => {
|
|
193
193
|
config.message = `[${helperName}] ${config.message}`
|
|
194
194
|
config.name = `${helperName}_${config.name}`
|
|
195
195
|
config.type = config.type || 'input'
|
|
@@ -225,9 +225,7 @@ module.exports = function (initPath) {
|
|
|
225
225
|
fs.writeFileSync(typeScriptconfigFile, configSource, 'utf-8')
|
|
226
226
|
print(`Config created at ${typeScriptconfigFile}`)
|
|
227
227
|
} else {
|
|
228
|
-
configSource = beautify(
|
|
229
|
-
`/** @type {CodeceptJS.MainConfig} */\nexports.config = ${inspect(config, false, 4, false)}`,
|
|
230
|
-
)
|
|
228
|
+
configSource = beautify(`/** @type {CodeceptJS.MainConfig} */\nexports.config = ${inspect(config, false, 4, false)}`)
|
|
231
229
|
|
|
232
230
|
if (hasConfigure) configSource = requireCodeceptConfigure + configHeader + configSource
|
|
233
231
|
|
|
@@ -286,9 +284,7 @@ module.exports = function (initPath) {
|
|
|
286
284
|
}
|
|
287
285
|
}
|
|
288
286
|
|
|
289
|
-
const generateDefinitionsManually = colors.bold(
|
|
290
|
-
`To get auto-completion support, please generate type definitions: ${colors.green('npx codeceptjs def')}`,
|
|
291
|
-
)
|
|
287
|
+
const generateDefinitionsManually = colors.bold(`To get auto-completion support, please generate type definitions: ${colors.green('npx codeceptjs def')}`)
|
|
292
288
|
|
|
293
289
|
if (packages) {
|
|
294
290
|
try {
|
|
@@ -330,7 +326,7 @@ module.exports = function (initPath) {
|
|
|
330
326
|
}
|
|
331
327
|
|
|
332
328
|
print('Configure helpers...')
|
|
333
|
-
inquirer.prompt(helperConfigs).then(async
|
|
329
|
+
inquirer.prompt(helperConfigs).then(async helperResult => {
|
|
334
330
|
if (helperResult.Playwright_browser === 'electron') {
|
|
335
331
|
delete helperResult.Playwright_url
|
|
336
332
|
delete helperResult.Playwright_show
|
|
@@ -341,7 +337,7 @@ module.exports = function (initPath) {
|
|
|
341
337
|
}
|
|
342
338
|
}
|
|
343
339
|
|
|
344
|
-
Object.keys(helperResult).forEach(
|
|
340
|
+
Object.keys(helperResult).forEach(key => {
|
|
345
341
|
const parts = key.split('_')
|
|
346
342
|
const helperName = parts[0]
|
|
347
343
|
const configName = parts[1]
|
|
@@ -4,7 +4,7 @@ const Codecept = require('../codecept')
|
|
|
4
4
|
const Container = require('../container')
|
|
5
5
|
const event = require('../event')
|
|
6
6
|
const output = require('../output')
|
|
7
|
-
const webHelpers =
|
|
7
|
+
const webHelpers = Container.STANDARD_ACTING_HELPERS
|
|
8
8
|
|
|
9
9
|
module.exports = async function (path, options) {
|
|
10
10
|
// Backward compatibility for --profile
|
|
@@ -39,7 +39,7 @@ module.exports = async function (path, options) {
|
|
|
39
39
|
if (webHelpers.includes(helperName)) {
|
|
40
40
|
const I = enabledHelpers[helperName]
|
|
41
41
|
recorder.add(() => I.amOnPage('/'))
|
|
42
|
-
recorder.catchWithoutStop(
|
|
42
|
+
recorder.catchWithoutStop(e => output.print(`Error while loading home page: ${e.message}}`))
|
|
43
43
|
break
|
|
44
44
|
}
|
|
45
45
|
}
|
package/lib/command/list.js
CHANGED
|
@@ -17,7 +17,7 @@ module.exports = function (path) {
|
|
|
17
17
|
const actions = []
|
|
18
18
|
for (const name in helpers) {
|
|
19
19
|
const helper = helpers[name]
|
|
20
|
-
methodsOfObject(helper).forEach(
|
|
20
|
+
methodsOfObject(helper).forEach(action => {
|
|
21
21
|
const params = getParamsToString(helper[action])
|
|
22
22
|
actions[action] = 1
|
|
23
23
|
output.print(` ${output.colors.grey(name)} I.${output.colors.bold(action)}(${params})`)
|
|
@@ -11,20 +11,7 @@ const { getConfig, getTestRoot, fail } = require('./utils')
|
|
|
11
11
|
const runner = path.join(__dirname, '/../../bin/codecept')
|
|
12
12
|
let config
|
|
13
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
|
-
]
|
|
14
|
+
const copyOptions = ['override', 'steps', 'reporter', 'verbose', 'config', 'reporter-options', 'grep', 'fgrep', 'invert', 'debug', 'plugins', 'colors']
|
|
28
15
|
let overrides = {}
|
|
29
16
|
|
|
30
17
|
// codeceptjs run-multiple smoke:chrome regression:firefox - will launch smoke run in chrome and regression in firefox
|
|
@@ -49,8 +36,8 @@ module.exports = async function (selectedRuns, options) {
|
|
|
49
36
|
|
|
50
37
|
// copy opts to run
|
|
51
38
|
Object.keys(options)
|
|
52
|
-
.filter(
|
|
53
|
-
.forEach(
|
|
39
|
+
.filter(key => copyOptions.indexOf(key) > -1)
|
|
40
|
+
.forEach(key => {
|
|
54
41
|
childOpts[key] = options[key]
|
|
55
42
|
})
|
|
56
43
|
|
|
@@ -96,12 +83,12 @@ module.exports = async function (selectedRuns, options) {
|
|
|
96
83
|
config.gherkin.features = ''
|
|
97
84
|
}
|
|
98
85
|
|
|
99
|
-
const childProcessesPromise = new Promise(
|
|
86
|
+
const childProcessesPromise = new Promise(resolve => {
|
|
100
87
|
processesDone = resolve
|
|
101
88
|
})
|
|
102
89
|
|
|
103
90
|
const runsToExecute = []
|
|
104
|
-
collection.createRuns(selectedRuns, config).forEach(
|
|
91
|
+
collection.createRuns(selectedRuns, config).forEach(run => {
|
|
105
92
|
const runName = run.getOriginalName() || run.getName()
|
|
106
93
|
const runConfig = run.getConfig()
|
|
107
94
|
runsToExecute.push(executeRun(runName, runConfig))
|
|
@@ -113,7 +100,7 @@ module.exports = async function (selectedRuns, options) {
|
|
|
113
100
|
|
|
114
101
|
// Execute all forks
|
|
115
102
|
totalSubprocessCount = runsToExecute.length
|
|
116
|
-
runsToExecute.forEach(
|
|
103
|
+
runsToExecute.forEach(runToExecute => runToExecute.call(this))
|
|
117
104
|
|
|
118
105
|
return childProcessesPromise.then(async () => {
|
|
119
106
|
// fire hook
|
|
@@ -149,11 +136,7 @@ function executeRun(runName, runConfig) {
|
|
|
149
136
|
// tweaking default output directories and for mochawesome
|
|
150
137
|
overriddenConfig = replaceValueDeep(overriddenConfig, 'output', path.join(config.output, outputDir))
|
|
151
138
|
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
|
-
)
|
|
139
|
+
overriddenConfig = replaceValueDeep(overriddenConfig, 'mochaFile', path.join(config.output, outputDir, `${browserName}_report.xml`))
|
|
157
140
|
|
|
158
141
|
// override tests configuration
|
|
159
142
|
if (overriddenConfig.tests) {
|
|
@@ -165,15 +148,9 @@ function executeRun(runName, runConfig) {
|
|
|
165
148
|
}
|
|
166
149
|
|
|
167
150
|
// override grep param and collect all params
|
|
168
|
-
const params = [
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
`${runId++}.${runName}:${browserName}`,
|
|
172
|
-
'--override',
|
|
173
|
-
JSON.stringify(overriddenConfig),
|
|
174
|
-
]
|
|
175
|
-
|
|
176
|
-
Object.keys(childOpts).forEach((key) => {
|
|
151
|
+
const params = ['run', '--child', `${runId++}.${runName}:${browserName}`, '--override', JSON.stringify(overriddenConfig)]
|
|
152
|
+
|
|
153
|
+
Object.keys(childOpts).forEach(key => {
|
|
177
154
|
params.push(`--${key}`)
|
|
178
155
|
if (childOpts[key] !== true) params.push(childOpts[key])
|
|
179
156
|
})
|
|
@@ -183,7 +160,7 @@ function executeRun(runName, runConfig) {
|
|
|
183
160
|
params.push(runConfig.grep)
|
|
184
161
|
}
|
|
185
162
|
|
|
186
|
-
const onProcessEnd =
|
|
163
|
+
const onProcessEnd = errorCode => {
|
|
187
164
|
if (errorCode !== 0) {
|
|
188
165
|
process.exitCode = errorCode
|
|
189
166
|
}
|
|
@@ -197,7 +174,7 @@ function executeRun(runName, runConfig) {
|
|
|
197
174
|
// Return function of fork for later execution
|
|
198
175
|
return () =>
|
|
199
176
|
fork(runner, params, { stdio: [0, 1, 2, 'ipc'] })
|
|
200
|
-
.on('exit',
|
|
177
|
+
.on('exit', code => {
|
|
201
178
|
return onProcessEnd(code)
|
|
202
179
|
})
|
|
203
180
|
.on('error', () => {
|
|
@@ -8,12 +8,6 @@ const Workers = require('../workers')
|
|
|
8
8
|
module.exports = async function (workerCount, selectedRuns, options) {
|
|
9
9
|
process.env.profile = options.profile
|
|
10
10
|
|
|
11
|
-
const suiteArr = []
|
|
12
|
-
const passedTestArr = []
|
|
13
|
-
const failedTestArr = []
|
|
14
|
-
const skippedTestArr = []
|
|
15
|
-
const stepArr = []
|
|
16
|
-
|
|
17
11
|
const { config: testConfig, override = '' } = options
|
|
18
12
|
const overrideConfigs = tryOrDefault(() => JSON.parse(override), {})
|
|
19
13
|
const by = options.suites ? 'suite' : 'test'
|
|
@@ -30,69 +24,24 @@ module.exports = async function (workerCount, selectedRuns, options) {
|
|
|
30
24
|
output.print(`CodeceptJS v${require('../codecept').version()} ${output.standWithUkraine()}`)
|
|
31
25
|
output.print(`Running tests in ${output.styles.bold(numberOfWorkers)} workers...`)
|
|
32
26
|
output.print()
|
|
27
|
+
store.hasWorkers = true
|
|
33
28
|
|
|
34
29
|
const workers = new Workers(numberOfWorkers, config)
|
|
35
30
|
workers.overrideConfig(overrideConfigs)
|
|
36
31
|
|
|
37
|
-
workers.on(event.
|
|
38
|
-
suiteArr.push(suite)
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
workers.on(event.step.passed, (step) => {
|
|
42
|
-
stepArr.push(step)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
workers.on(event.step.failed, (step) => {
|
|
46
|
-
stepArr.push(step)
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
workers.on(event.test.failed, (test) => {
|
|
50
|
-
failedTestArr.push(test)
|
|
32
|
+
workers.on(event.test.failed, test => {
|
|
51
33
|
output.test.failed(test)
|
|
52
34
|
})
|
|
53
35
|
|
|
54
|
-
workers.on(event.test.passed,
|
|
55
|
-
passedTestArr.push(test)
|
|
36
|
+
workers.on(event.test.passed, test => {
|
|
56
37
|
output.test.passed(test)
|
|
57
38
|
})
|
|
58
39
|
|
|
59
|
-
workers.on(event.test.skipped,
|
|
60
|
-
skippedTestArr.push(test)
|
|
40
|
+
workers.on(event.test.skipped, test => {
|
|
61
41
|
output.test.skipped(test)
|
|
62
42
|
})
|
|
63
43
|
|
|
64
|
-
workers.on(event.all.result,
|
|
65
|
-
// expose test stats after all workers finished their execution
|
|
66
|
-
function addStepsToTest(test, stepArr) {
|
|
67
|
-
stepArr.test.steps.forEach((step) => {
|
|
68
|
-
if (test.steps.length === 0) {
|
|
69
|
-
test.steps.push(step)
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
stepArr.forEach((step) => {
|
|
75
|
-
passedTestArr.forEach((test) => {
|
|
76
|
-
if (step.test.title === test.title) {
|
|
77
|
-
addStepsToTest(test, step)
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
failedTestArr.forEach((test) => {
|
|
82
|
-
if (step.test.title === test.title) {
|
|
83
|
-
addStepsToTest(test, step)
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
event.dispatcher.emit(event.workers.result, {
|
|
89
|
-
suites: suiteArr,
|
|
90
|
-
tests: {
|
|
91
|
-
passed: passedTestArr,
|
|
92
|
-
failed: failedTestArr,
|
|
93
|
-
skipped: skippedTestArr,
|
|
94
|
-
},
|
|
95
|
-
})
|
|
44
|
+
workers.on(event.all.result, result => {
|
|
96
45
|
workers.printResults()
|
|
97
46
|
})
|
|
98
47
|
|
|
@@ -100,7 +49,6 @@ module.exports = async function (workerCount, selectedRuns, options) {
|
|
|
100
49
|
if (options.verbose || options.debug) store.debugMode = true
|
|
101
50
|
|
|
102
51
|
if (options.verbose) {
|
|
103
|
-
global.debugMode = true
|
|
104
52
|
const { getMachineInfo } = require('./info')
|
|
105
53
|
await getMachineInfo()
|
|
106
54
|
}
|
package/lib/command/utils.js
CHANGED
|
@@ -29,8 +29,7 @@ module.exports.readConfig = function (configFile) {
|
|
|
29
29
|
function getTestRoot(currentPath) {
|
|
30
30
|
if (!currentPath) currentPath = '.'
|
|
31
31
|
if (!path.isAbsolute(currentPath)) currentPath = path.join(process.cwd(), currentPath)
|
|
32
|
-
currentPath =
|
|
33
|
-
fs.lstatSync(currentPath).isDirectory() || !path.extname(currentPath) ? currentPath : path.dirname(currentPath)
|
|
32
|
+
currentPath = fs.lstatSync(currentPath).isDirectory() || !path.extname(currentPath) ? currentPath : path.dirname(currentPath)
|
|
34
33
|
return currentPath
|
|
35
34
|
}
|
|
36
35
|
module.exports.getTestRoot = getTestRoot
|
|
@@ -71,7 +70,7 @@ function safeFileWrite(file, contents) {
|
|
|
71
70
|
|
|
72
71
|
module.exports.safeFileWrite = safeFileWrite
|
|
73
72
|
|
|
74
|
-
module.exports.captureStream =
|
|
73
|
+
module.exports.captureStream = stream => {
|
|
75
74
|
let oldStream
|
|
76
75
|
let buffer = ''
|
|
77
76
|
|
|
@@ -79,7 +78,7 @@ module.exports.captureStream = (stream) => {
|
|
|
79
78
|
startCapture() {
|
|
80
79
|
buffer = ''
|
|
81
80
|
oldStream = stream.write.bind(stream)
|
|
82
|
-
stream.write =
|
|
81
|
+
stream.write = chunk => (buffer += chunk)
|
|
83
82
|
},
|
|
84
83
|
stopCapture() {
|
|
85
84
|
if (oldStream !== undefined) stream.write = oldStream
|
|
@@ -88,7 +87,7 @@ module.exports.captureStream = (stream) => {
|
|
|
88
87
|
}
|
|
89
88
|
}
|
|
90
89
|
|
|
91
|
-
module.exports.printError =
|
|
90
|
+
module.exports.printError = err => {
|
|
92
91
|
output.print('')
|
|
93
92
|
output.error(err.message)
|
|
94
93
|
output.print('')
|
|
@@ -106,7 +105,7 @@ module.exports.createOutputDir = (config, testRoot) => {
|
|
|
106
105
|
}
|
|
107
106
|
}
|
|
108
107
|
|
|
109
|
-
module.exports.findConfigFile =
|
|
108
|
+
module.exports.findConfigFile = testsPath => {
|
|
110
109
|
const extensions = ['js', 'ts']
|
|
111
110
|
for (const ext of extensions) {
|
|
112
111
|
const configFile = path.join(testsPath, `codecept.conf.${ext}`)
|