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,92 +1,89 @@
|
|
|
1
1
|
// For Node version >=10.5.0, have to use experimental flag
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const by = options.suites ? 'suite' : 'test';
|
|
22
|
-
delete options.parent;
|
|
2
|
+
const { tryOrDefault } = require('../utils')
|
|
3
|
+
const output = require('../output')
|
|
4
|
+
const store = require('../store')
|
|
5
|
+
const event = require('../event')
|
|
6
|
+
const Workers = require('../workers')
|
|
7
|
+
|
|
8
|
+
module.exports = async function (workerCount, selectedRuns, options) {
|
|
9
|
+
process.env.profile = options.profile
|
|
10
|
+
|
|
11
|
+
const suiteArr = []
|
|
12
|
+
const passedTestArr = []
|
|
13
|
+
const failedTestArr = []
|
|
14
|
+
const skippedTestArr = []
|
|
15
|
+
const stepArr = []
|
|
16
|
+
|
|
17
|
+
const { config: testConfig, override = '' } = options
|
|
18
|
+
const overrideConfigs = tryOrDefault(() => JSON.parse(override), {})
|
|
19
|
+
const by = options.suites ? 'suite' : 'test'
|
|
20
|
+
delete options.parent
|
|
23
21
|
const config = {
|
|
24
22
|
by,
|
|
25
23
|
testConfig,
|
|
26
24
|
options,
|
|
27
25
|
selectedRuns,
|
|
28
|
-
}
|
|
26
|
+
}
|
|
29
27
|
|
|
30
|
-
const numberOfWorkers = parseInt(workerCount, 10)
|
|
28
|
+
const numberOfWorkers = parseInt(workerCount, 10)
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
output.print(`
|
|
34
|
-
output.print(
|
|
35
|
-
output.print();
|
|
30
|
+
output.print(`CodeceptJS v${require('../codecept').version()} ${output.standWithUkraine()}`)
|
|
31
|
+
output.print(`Running tests in ${output.styles.bold(numberOfWorkers)} workers...`)
|
|
32
|
+
output.print()
|
|
36
33
|
|
|
37
|
-
const workers = new Workers(numberOfWorkers, config)
|
|
38
|
-
workers.overrideConfig(overrideConfigs)
|
|
34
|
+
const workers = new Workers(numberOfWorkers, config)
|
|
35
|
+
workers.overrideConfig(overrideConfigs)
|
|
39
36
|
|
|
40
37
|
workers.on(event.suite.before, (suite) => {
|
|
41
|
-
suiteArr.push(suite)
|
|
42
|
-
})
|
|
38
|
+
suiteArr.push(suite)
|
|
39
|
+
})
|
|
43
40
|
|
|
44
41
|
workers.on(event.step.passed, (step) => {
|
|
45
|
-
stepArr.push(step)
|
|
46
|
-
})
|
|
42
|
+
stepArr.push(step)
|
|
43
|
+
})
|
|
47
44
|
|
|
48
45
|
workers.on(event.step.failed, (step) => {
|
|
49
|
-
stepArr.push(step)
|
|
50
|
-
})
|
|
46
|
+
stepArr.push(step)
|
|
47
|
+
})
|
|
51
48
|
|
|
52
49
|
workers.on(event.test.failed, (test) => {
|
|
53
|
-
failedTestArr.push(test)
|
|
54
|
-
output.
|
|
55
|
-
})
|
|
50
|
+
failedTestArr.push(test)
|
|
51
|
+
output.test.failed(test)
|
|
52
|
+
})
|
|
56
53
|
|
|
57
54
|
workers.on(event.test.passed, (test) => {
|
|
58
|
-
passedTestArr.push(test)
|
|
59
|
-
output.
|
|
60
|
-
})
|
|
55
|
+
passedTestArr.push(test)
|
|
56
|
+
output.test.passed(test)
|
|
57
|
+
})
|
|
61
58
|
|
|
62
59
|
workers.on(event.test.skipped, (test) => {
|
|
63
|
-
skippedTestArr.push(test)
|
|
64
|
-
output.
|
|
65
|
-
})
|
|
60
|
+
skippedTestArr.push(test)
|
|
61
|
+
output.test.skipped(test)
|
|
62
|
+
})
|
|
66
63
|
|
|
67
64
|
workers.on(event.all.result, () => {
|
|
68
65
|
// expose test stats after all workers finished their execution
|
|
69
66
|
function addStepsToTest(test, stepArr) {
|
|
70
|
-
stepArr.test.steps.forEach(step => {
|
|
67
|
+
stepArr.test.steps.forEach((step) => {
|
|
71
68
|
if (test.steps.length === 0) {
|
|
72
|
-
test.steps.push(step)
|
|
69
|
+
test.steps.push(step)
|
|
73
70
|
}
|
|
74
|
-
})
|
|
71
|
+
})
|
|
75
72
|
}
|
|
76
73
|
|
|
77
|
-
stepArr.forEach(step => {
|
|
78
|
-
passedTestArr.forEach(test => {
|
|
74
|
+
stepArr.forEach((step) => {
|
|
75
|
+
passedTestArr.forEach((test) => {
|
|
79
76
|
if (step.test.title === test.title) {
|
|
80
|
-
addStepsToTest(test, step)
|
|
77
|
+
addStepsToTest(test, step)
|
|
81
78
|
}
|
|
82
|
-
})
|
|
79
|
+
})
|
|
83
80
|
|
|
84
|
-
failedTestArr.forEach(test => {
|
|
81
|
+
failedTestArr.forEach((test) => {
|
|
85
82
|
if (step.test.title === test.title) {
|
|
86
|
-
addStepsToTest(test, step)
|
|
83
|
+
addStepsToTest(test, step)
|
|
87
84
|
}
|
|
88
|
-
})
|
|
89
|
-
})
|
|
85
|
+
})
|
|
86
|
+
})
|
|
90
87
|
|
|
91
88
|
event.dispatcher.emit(event.workers.result, {
|
|
92
89
|
suites: suiteArr,
|
|
@@ -95,23 +92,24 @@ export default async function (workerCount, selectedRuns, options) {
|
|
|
95
92
|
failed: failedTestArr,
|
|
96
93
|
skipped: skippedTestArr,
|
|
97
94
|
},
|
|
98
|
-
})
|
|
99
|
-
workers.printResults()
|
|
100
|
-
})
|
|
95
|
+
})
|
|
96
|
+
workers.printResults()
|
|
97
|
+
})
|
|
101
98
|
|
|
102
99
|
try {
|
|
103
|
-
if (options.verbose || options.debug) store.debugMode = true
|
|
100
|
+
if (options.verbose || options.debug) store.debugMode = true
|
|
104
101
|
|
|
105
102
|
if (options.verbose) {
|
|
106
|
-
global.debugMode = true
|
|
107
|
-
|
|
103
|
+
global.debugMode = true
|
|
104
|
+
const { getMachineInfo } = require('./info')
|
|
105
|
+
await getMachineInfo()
|
|
108
106
|
}
|
|
109
|
-
await workers.bootstrapAll()
|
|
110
|
-
await workers.run()
|
|
107
|
+
await workers.bootstrapAll()
|
|
108
|
+
await workers.run()
|
|
111
109
|
} catch (err) {
|
|
112
|
-
output.
|
|
113
|
-
process.exit(1)
|
|
110
|
+
output.error(err)
|
|
111
|
+
process.exit(1)
|
|
114
112
|
} finally {
|
|
115
|
-
await workers.teardownAll()
|
|
113
|
+
await workers.teardownAll()
|
|
116
114
|
}
|
|
117
115
|
}
|
package/lib/command/run.js
CHANGED
|
@@ -1,49 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { store } from '../store.js';
|
|
8
|
-
|
|
9
|
-
export default async function (test, options) {
|
|
1
|
+
const { getConfig, printError, getTestRoot, createOutputDir } = require('./utils')
|
|
2
|
+
const Config = require('../config')
|
|
3
|
+
const store = require('../store')
|
|
4
|
+
const Codecept = require('../codecept')
|
|
5
|
+
|
|
6
|
+
module.exports = async function (test, options) {
|
|
10
7
|
// registering options globally to use in config
|
|
11
8
|
// Backward compatibility for --profile
|
|
12
9
|
// TODO: remove in CodeceptJS 4
|
|
13
|
-
process.profile = options.profile
|
|
10
|
+
process.profile = options.profile
|
|
14
11
|
|
|
15
12
|
if (options.profile) {
|
|
16
|
-
process.env.profile = options.profile
|
|
13
|
+
process.env.profile = options.profile
|
|
17
14
|
}
|
|
18
|
-
if (options.verbose || options.debug) store.debugMode = true
|
|
19
|
-
|
|
20
|
-
const configFile = options.config;
|
|
15
|
+
if (options.verbose || options.debug) store.debugMode = true
|
|
21
16
|
|
|
22
|
-
|
|
17
|
+
const configFile = options.config
|
|
23
18
|
|
|
19
|
+
let config = getConfig(configFile)
|
|
24
20
|
if (options.override) {
|
|
25
|
-
config = Config.append(JSON.parse(options.override))
|
|
21
|
+
config = Config.append(JSON.parse(options.override))
|
|
26
22
|
}
|
|
27
|
-
const testRoot = getTestRoot(configFile)
|
|
28
|
-
createOutputDir(config, testRoot)
|
|
23
|
+
const testRoot = getTestRoot(configFile)
|
|
24
|
+
createOutputDir(config, testRoot)
|
|
25
|
+
|
|
26
|
+
const codecept = new Codecept(config, options)
|
|
29
27
|
|
|
30
|
-
const codecept = new Codecept(config, options);
|
|
31
28
|
try {
|
|
32
|
-
codecept.init(testRoot)
|
|
33
|
-
await codecept.bootstrap()
|
|
34
|
-
codecept.loadTests(test)
|
|
29
|
+
codecept.init(testRoot)
|
|
30
|
+
await codecept.bootstrap()
|
|
31
|
+
codecept.loadTests(test)
|
|
35
32
|
|
|
36
33
|
if (options.verbose) {
|
|
37
|
-
global.debugMode = true
|
|
38
|
-
const { getMachineInfo } =
|
|
39
|
-
await getMachineInfo()
|
|
34
|
+
global.debugMode = true
|
|
35
|
+
const { getMachineInfo } = require('./info')
|
|
36
|
+
await getMachineInfo()
|
|
40
37
|
}
|
|
41
38
|
|
|
42
|
-
await codecept.run()
|
|
39
|
+
await codecept.run()
|
|
43
40
|
} catch (err) {
|
|
44
|
-
printError(err)
|
|
45
|
-
process.exitCode = 1
|
|
41
|
+
printError(err)
|
|
42
|
+
process.exitCode = 1
|
|
46
43
|
} finally {
|
|
47
|
-
await codecept.teardown()
|
|
44
|
+
await codecept.teardown()
|
|
48
45
|
}
|
|
49
46
|
}
|
package/lib/command/utils.js
CHANGED
|
@@ -1,103 +1,118 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
const util = require('util')
|
|
4
|
+
const mkdirp = require('mkdirp')
|
|
5
|
+
|
|
6
|
+
const output = require('../output')
|
|
7
|
+
const { fileExists, beautify } = require('../utils')
|
|
8
|
+
|
|
9
|
+
// alias to deep merge
|
|
10
|
+
module.exports.deepMerge = require('../utils').deepMerge
|
|
11
|
+
|
|
12
|
+
module.exports.getConfig = function (configFile) {
|
|
10
13
|
try {
|
|
11
|
-
return config.
|
|
14
|
+
return require('../config').load(configFile)
|
|
12
15
|
} catch (err) {
|
|
13
|
-
fail(err.stack)
|
|
16
|
+
fail(err.stack)
|
|
14
17
|
}
|
|
15
|
-
}
|
|
18
|
+
}
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
module.exports.readConfig = function (configFile) {
|
|
18
21
|
try {
|
|
19
|
-
const data = fs.readFileSync(configFile, 'utf8')
|
|
20
|
-
return data
|
|
22
|
+
const data = fs.readFileSync(configFile, 'utf8')
|
|
23
|
+
return data
|
|
21
24
|
} catch (err) {
|
|
22
|
-
output.
|
|
25
|
+
output.error(err)
|
|
23
26
|
}
|
|
24
|
-
}
|
|
27
|
+
}
|
|
25
28
|
|
|
26
29
|
function getTestRoot(currentPath) {
|
|
27
|
-
if (!currentPath) currentPath = '.'
|
|
28
|
-
if (!path.isAbsolute(currentPath)) currentPath = path.join(process.cwd(), currentPath)
|
|
29
|
-
currentPath =
|
|
30
|
-
|
|
30
|
+
if (!currentPath) currentPath = '.'
|
|
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)
|
|
34
|
+
return currentPath
|
|
31
35
|
}
|
|
32
|
-
|
|
36
|
+
module.exports.getTestRoot = getTestRoot
|
|
33
37
|
|
|
34
38
|
function fail(msg) {
|
|
35
|
-
output.
|
|
36
|
-
process.exit(1)
|
|
39
|
+
output.error(msg)
|
|
40
|
+
process.exit(1)
|
|
37
41
|
}
|
|
38
42
|
|
|
39
|
-
|
|
43
|
+
module.exports.fail = fail
|
|
40
44
|
|
|
41
|
-
function updateConfig(testsPath, config,
|
|
42
|
-
const configFile = path.join(testsPath, `codecept.conf.${extension}`)
|
|
45
|
+
function updateConfig(testsPath, config, extension) {
|
|
46
|
+
const configFile = path.join(testsPath, `codecept.conf.${extension}`)
|
|
43
47
|
if (!fileExists(configFile)) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
console.log(`${output.
|
|
47
|
-
console.log('Please update it manually:')
|
|
48
|
-
console.log()
|
|
49
|
-
console.log(
|
|
50
|
-
console.log()
|
|
51
|
-
return
|
|
48
|
+
const msg = `codecept.conf.${extension} config can\'t be updated automatically`
|
|
49
|
+
console.log()
|
|
50
|
+
console.log(`${output.colors.bold.red(msg)}`)
|
|
51
|
+
console.log(`${output.colors.bold.red('Please update it manually:')}`)
|
|
52
|
+
console.log()
|
|
53
|
+
console.log(config)
|
|
54
|
+
console.log()
|
|
55
|
+
return
|
|
52
56
|
}
|
|
53
|
-
console.log(`${output.
|
|
54
|
-
return fs.writeFileSync(configFile, beautify(`exports.config = ${util.inspect(config, false, 4, false)}`), 'utf-8')
|
|
57
|
+
console.log(`${output.colors.yellow('Updating configuration file...')}`)
|
|
58
|
+
return fs.writeFileSync(configFile, beautify(`exports.config = ${util.inspect(config, false, 4, false)}`), 'utf-8')
|
|
55
59
|
}
|
|
56
60
|
|
|
57
|
-
|
|
61
|
+
module.exports.updateConfig = updateConfig
|
|
58
62
|
|
|
59
63
|
function safeFileWrite(file, contents) {
|
|
60
64
|
if (fileExists(file)) {
|
|
61
|
-
output.
|
|
62
|
-
return false
|
|
65
|
+
output.error(`File ${file} already exist, skipping...`)
|
|
66
|
+
return false
|
|
63
67
|
}
|
|
64
|
-
fs.writeFileSync(file, contents)
|
|
65
|
-
return true
|
|
68
|
+
fs.writeFileSync(file, contents)
|
|
69
|
+
return true
|
|
66
70
|
}
|
|
67
71
|
|
|
68
|
-
|
|
72
|
+
module.exports.safeFileWrite = safeFileWrite
|
|
69
73
|
|
|
70
|
-
|
|
71
|
-
let oldStream
|
|
72
|
-
let buffer = ''
|
|
74
|
+
module.exports.captureStream = (stream) => {
|
|
75
|
+
let oldStream
|
|
76
|
+
let buffer = ''
|
|
73
77
|
|
|
74
78
|
return {
|
|
75
79
|
startCapture() {
|
|
76
|
-
buffer = ''
|
|
77
|
-
oldStream = stream.write.bind(stream)
|
|
78
|
-
stream.write = chunk => (buffer += chunk)
|
|
80
|
+
buffer = ''
|
|
81
|
+
oldStream = stream.write.bind(stream)
|
|
82
|
+
stream.write = (chunk) => (buffer += chunk)
|
|
79
83
|
},
|
|
80
84
|
stopCapture() {
|
|
81
|
-
if (oldStream !== undefined) stream.write = oldStream
|
|
85
|
+
if (oldStream !== undefined) stream.write = oldStream
|
|
82
86
|
},
|
|
83
87
|
getData: () => buffer,
|
|
84
|
-
}
|
|
85
|
-
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
86
90
|
|
|
87
|
-
|
|
88
|
-
output.print('')
|
|
89
|
-
output.
|
|
90
|
-
output.print('')
|
|
91
|
-
output.print(output.
|
|
92
|
-
}
|
|
91
|
+
module.exports.printError = (err) => {
|
|
92
|
+
output.print('')
|
|
93
|
+
output.error(err.message)
|
|
94
|
+
output.print('')
|
|
95
|
+
output.print(output.colors.grey(err.stack.replace(err.message, '')))
|
|
96
|
+
}
|
|
93
97
|
|
|
94
|
-
|
|
95
|
-
let outputDir
|
|
96
|
-
if (path.isAbsolute(config.output)) outputDir = config.output
|
|
97
|
-
else outputDir = path.join(testRoot, config.output)
|
|
98
|
+
module.exports.createOutputDir = (config, testRoot) => {
|
|
99
|
+
let outputDir
|
|
100
|
+
if (path.isAbsolute(config.output)) outputDir = config.output
|
|
101
|
+
else outputDir = path.join(testRoot, config.output)
|
|
98
102
|
|
|
99
103
|
if (!fileExists(outputDir)) {
|
|
100
|
-
output.print(`creating output directory: ${outputDir}`)
|
|
101
|
-
mkdirp.sync(outputDir)
|
|
104
|
+
output.print(`creating output directory: ${outputDir}`)
|
|
105
|
+
mkdirp.sync(outputDir)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
module.exports.findConfigFile = (testsPath) => {
|
|
110
|
+
const extensions = ['js', 'ts']
|
|
111
|
+
for (const ext of extensions) {
|
|
112
|
+
const configFile = path.join(testsPath, `codecept.conf.${ext}`)
|
|
113
|
+
if (fileExists(configFile)) {
|
|
114
|
+
return configFile
|
|
115
|
+
}
|
|
102
116
|
}
|
|
103
|
-
|
|
117
|
+
return null
|
|
118
|
+
}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { parentPort, workerData } from 'worker_threads';
|
|
3
|
-
import * as event from '../../event.js';
|
|
4
|
-
import Container from '../../container.js';
|
|
5
|
-
import { getConfig } from '../utils.js';
|
|
6
|
-
import { deepMerge, tryOrDefault } from '../../utils.js';
|
|
7
|
-
import Codecept from '../../codecept.js';
|
|
1
|
+
const tty = require('tty');
|
|
8
2
|
|
|
9
3
|
if (!tty.getWindowSize) {
|
|
10
4
|
// this is really old method, long removed from Node, but Mocha
|
|
@@ -13,13 +7,19 @@ if (!tty.getWindowSize) {
|
|
|
13
7
|
tty.getWindowSize = () => [40, 80];
|
|
14
8
|
}
|
|
15
9
|
|
|
10
|
+
const { parentPort, workerData } = require('worker_threads');
|
|
11
|
+
const event = require('../../event');
|
|
12
|
+
const container = require('../../container');
|
|
13
|
+
const { getConfig } = require('../utils');
|
|
14
|
+
const { tryOrDefault, deepMerge } = require('../../utils');
|
|
15
|
+
|
|
16
16
|
// eslint-disable-next-line no-unused-vars
|
|
17
17
|
let stdout = '';
|
|
18
18
|
/* eslint-enable no-unused-vars */
|
|
19
19
|
const stderr = '';
|
|
20
20
|
|
|
21
21
|
// Requiring of Codecept need to be after tty.getWindowSize is available.
|
|
22
|
-
|
|
22
|
+
const Codecept = require(process.env.CODECEPT_CLASS_PATH || '../../codecept');
|
|
23
23
|
|
|
24
24
|
const {
|
|
25
25
|
options, tests, testRoot, workerIndex,
|
|
@@ -37,7 +37,7 @@ const config = deepMerge(getConfig(options.config || testRoot), overrideConfigs)
|
|
|
37
37
|
const codecept = new Codecept(config, options);
|
|
38
38
|
codecept.init(testRoot);
|
|
39
39
|
codecept.loadTests();
|
|
40
|
-
const mocha =
|
|
40
|
+
const mocha = container.mocha();
|
|
41
41
|
filterTests();
|
|
42
42
|
|
|
43
43
|
(async function () {
|
|
@@ -287,6 +287,6 @@ function sendToParentThread(data) {
|
|
|
287
287
|
|
|
288
288
|
function listenToParentThread() {
|
|
289
289
|
parentPort.on('message', (eventData) => {
|
|
290
|
-
|
|
290
|
+
container.append({ support: eventData.data });
|
|
291
291
|
});
|
|
292
292
|
}
|
package/lib/config.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const {
|
|
4
|
+
fileExists,
|
|
5
|
+
isFile,
|
|
6
|
+
deepMerge,
|
|
7
|
+
deepClone,
|
|
8
|
+
} = require('./utils');
|
|
7
9
|
|
|
8
10
|
const defaultConfig = {
|
|
9
11
|
output: './_output',
|
|
@@ -140,7 +142,7 @@ class Config {
|
|
|
140
142
|
}
|
|
141
143
|
}
|
|
142
144
|
|
|
143
|
-
|
|
145
|
+
module.exports = Config;
|
|
144
146
|
|
|
145
147
|
function loadConfigFile(configFile) {
|
|
146
148
|
const extensionName = path.extname(configFile);
|
|
@@ -155,8 +157,7 @@ function loadConfigFile(configFile) {
|
|
|
155
157
|
|
|
156
158
|
// .conf.js config file
|
|
157
159
|
if (extensionName === '.js' || extensionName === '.ts' || extensionName === '.cjs') {
|
|
158
|
-
|
|
159
|
-
return Config.create(config);
|
|
160
|
+
return Config.create(require(configFile).config);
|
|
160
161
|
}
|
|
161
162
|
|
|
162
163
|
// json config provided
|