codeceptjs 3.6.6 → 4.0.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/bin/codecept.js +81 -84
- package/lib/actor.js +13 -13
- package/lib/ai.js +13 -10
- package/lib/assert/empty.js +21 -20
- package/lib/assert/equal.js +39 -37
- package/lib/assert/error.js +14 -14
- package/lib/assert/include.js +47 -46
- package/lib/assert/throws.js +11 -13
- package/lib/assert/truth.js +22 -19
- package/lib/assert.js +2 -4
- package/lib/cli.js +49 -57
- package/lib/codecept.js +155 -142
- package/lib/colorUtils.js +3 -3
- package/lib/command/configMigrate.js +52 -58
- package/lib/command/definitions.js +89 -88
- package/lib/command/dryRun.js +68 -71
- package/lib/command/generate.js +188 -197
- package/lib/command/gherkin/init.js +16 -27
- package/lib/command/gherkin/snippets.js +20 -20
- package/lib/command/gherkin/steps.js +8 -8
- package/lib/command/info.js +38 -40
- package/lib/command/init.js +288 -290
- 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 +2 -6
- package/lib/command/run-multiple.js +93 -113
- package/lib/command/run-rerun.js +25 -20
- package/lib/command/run-workers.js +66 -64
- package/lib/command/run.js +29 -26
- package/lib/command/utils.js +65 -80
- package/lib/command/workers/runTests.js +10 -10
- package/lib/config.js +9 -10
- package/lib/container.js +48 -40
- package/lib/data/context.js +59 -60
- package/lib/data/dataScenarioConfig.js +47 -47
- package/lib/data/dataTableArgument.js +29 -29
- package/lib/data/table.js +20 -26
- package/lib/dirname.js +5 -0
- package/lib/event.js +167 -163
- package/lib/heal.js +17 -13
- package/lib/helper/AI.js +41 -130
- package/lib/helper/ApiDataFactory.js +69 -73
- package/lib/helper/Appium.js +381 -412
- package/lib/helper/Expect.js +425 -0
- package/lib/helper/ExpectHelper.js +48 -40
- package/lib/helper/FileSystem.js +79 -80
- package/lib/helper/GraphQL.js +43 -44
- package/lib/helper/GraphQLDataFactory.js +50 -50
- package/lib/helper/JSONResponse.js +62 -65
- package/lib/helper/Mochawesome.js +28 -28
- package/lib/helper/MockServer.js +14 -12
- package/lib/helper/Nightmare.js +566 -662
- package/lib/helper/Playwright.js +1216 -1361
- package/lib/helper/Protractor.js +627 -663
- package/lib/helper/Puppeteer.js +1128 -1231
- package/lib/helper/REST.js +68 -159
- package/lib/helper/SoftExpectHelper.js +2 -2
- package/lib/helper/TestCafe.js +484 -490
- package/lib/helper/WebDriver.js +1156 -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 +2 -2
- package/lib/helper/extras/PlaywrightReactVueLocator.js +1 -1
- package/lib/helper/extras/PlaywrightRestartOpts.js +18 -21
- package/lib/helper/extras/Popup.js +1 -1
- package/lib/helper/extras/React.js +3 -3
- package/lib/helper/network/actions.js +7 -14
- package/lib/helper/network/utils.js +2 -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 -6
- package/lib/helper.js +3 -1
- package/lib/history.js +5 -6
- package/lib/hooks.js +6 -6
- package/lib/html.js +7 -7
- package/lib/index.js +41 -25
- package/lib/interfaces/bdd.js +64 -47
- package/lib/interfaces/featureConfig.js +19 -19
- package/lib/interfaces/gherkin.js +118 -124
- 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 +30 -32
- package/lib/listener/steps.js +53 -50
- package/lib/listener/timeout.js +54 -54
- package/lib/locator.js +10 -6
- package/lib/mochaFactory.js +15 -18
- package/lib/output.js +10 -6
- package/lib/parser.js +12 -15
- package/lib/pause.js +33 -40
- package/lib/plugin/allure.js +15 -15
- package/lib/plugin/autoDelay.js +37 -29
- package/lib/plugin/autoLogin.js +65 -70
- package/lib/plugin/commentStep.js +18 -18
- package/lib/plugin/coverage.js +67 -115
- package/lib/plugin/customLocator.js +20 -21
- 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 +108 -67
- package/lib/plugin/pauseOnFail.js +11 -11
- package/lib/plugin/retryFailedStep.js +39 -32
- package/lib/plugin/retryTo.js +40 -46
- package/lib/plugin/screenshotOnFail.js +87 -109
- package/lib/plugin/selenoid.js +118 -131
- package/lib/plugin/standardActingHelpers.js +8 -2
- package/lib/plugin/stepByStepReport.js +91 -110
- package/lib/plugin/stepTimeout.js +23 -24
- package/lib/plugin/subtitles.js +35 -34
- package/lib/plugin/tryTo.js +30 -40
- package/lib/plugin/wdio.js +75 -78
- package/lib/recorder.js +17 -14
- package/lib/rerun.js +10 -11
- package/lib/scenario.js +23 -25
- package/lib/secret.js +2 -4
- package/lib/session.js +10 -10
- package/lib/step.js +9 -12
- package/lib/store.js +3 -2
- package/lib/transform.js +1 -1
- package/lib/translation.js +8 -7
- package/lib/ui.js +14 -12
- package/lib/utils.js +72 -70
- package/lib/within.js +10 -10
- package/lib/workerStorage.js +25 -27
- package/lib/workers.js +32 -29
- package/package.json +53 -51
- package/translations/de-DE.js +1 -1
- package/translations/fr-FR.js +1 -1
- package/translations/index.js +13 -9
- 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 +65 -415
- package/typings/promiseBasedTypes.d.ts +32 -0
- package/typings/types.d.ts +32 -0
|
@@ -1,89 +1,92 @@
|
|
|
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
|
-
|
|
2
|
+
import { tryOrDefault } from '../utils.js';
|
|
3
|
+
import { store } from '../store.js';
|
|
4
|
+
import * as output from '../output.js';
|
|
5
|
+
import * as event from '../event.js';
|
|
6
|
+
import { Workers } from '../workers.js';
|
|
7
|
+
import { getMachineInfo } from './info.js';
|
|
8
|
+
import * as Codecept from '../codecept.js';
|
|
9
|
+
|
|
10
|
+
export default async function (workerCount, selectedRuns, options) {
|
|
11
|
+
process.env.profile = options.profile;
|
|
12
|
+
|
|
13
|
+
const suiteArr = [];
|
|
14
|
+
const passedTestArr = [];
|
|
15
|
+
const failedTestArr = [];
|
|
16
|
+
const skippedTestArr = [];
|
|
17
|
+
const stepArr = [];
|
|
18
|
+
|
|
19
|
+
const { config: testConfig, override = '' } = options;
|
|
20
|
+
const overrideConfigs = tryOrDefault(() => JSON.parse(override), {});
|
|
21
|
+
const by = options.suites ? 'suite' : 'test';
|
|
22
|
+
delete options.parent;
|
|
21
23
|
const config = {
|
|
22
24
|
by,
|
|
23
25
|
testConfig,
|
|
24
26
|
options,
|
|
25
27
|
selectedRuns,
|
|
26
|
-
}
|
|
28
|
+
};
|
|
27
29
|
|
|
28
|
-
const numberOfWorkers = parseInt(workerCount, 10)
|
|
30
|
+
const numberOfWorkers = parseInt(workerCount, 10);
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
output.print(`
|
|
32
|
-
output.print()
|
|
32
|
+
const version = Codecept.version();
|
|
33
|
+
output.print(`CodeceptJS v${version} ${output.output.standWithUkraine()}`);
|
|
34
|
+
output.print(`Running tests in ${output.output.styles.bold(numberOfWorkers)} workers...`);
|
|
35
|
+
output.print();
|
|
33
36
|
|
|
34
|
-
const workers = new Workers(numberOfWorkers, config)
|
|
35
|
-
workers.overrideConfig(overrideConfigs)
|
|
37
|
+
const workers = new Workers(numberOfWorkers, config);
|
|
38
|
+
workers.overrideConfig(overrideConfigs);
|
|
36
39
|
|
|
37
40
|
workers.on(event.suite.before, (suite) => {
|
|
38
|
-
suiteArr.push(suite)
|
|
39
|
-
})
|
|
41
|
+
suiteArr.push(suite);
|
|
42
|
+
});
|
|
40
43
|
|
|
41
44
|
workers.on(event.step.passed, (step) => {
|
|
42
|
-
stepArr.push(step)
|
|
43
|
-
})
|
|
45
|
+
stepArr.push(step);
|
|
46
|
+
});
|
|
44
47
|
|
|
45
48
|
workers.on(event.step.failed, (step) => {
|
|
46
|
-
stepArr.push(step)
|
|
47
|
-
})
|
|
49
|
+
stepArr.push(step);
|
|
50
|
+
});
|
|
48
51
|
|
|
49
52
|
workers.on(event.test.failed, (test) => {
|
|
50
|
-
failedTestArr.push(test)
|
|
51
|
-
output.test.failed(test)
|
|
52
|
-
})
|
|
53
|
+
failedTestArr.push(test);
|
|
54
|
+
output.output.test.failed(test);
|
|
55
|
+
});
|
|
53
56
|
|
|
54
57
|
workers.on(event.test.passed, (test) => {
|
|
55
|
-
passedTestArr.push(test)
|
|
56
|
-
output.test.passed(test)
|
|
57
|
-
})
|
|
58
|
+
passedTestArr.push(test);
|
|
59
|
+
output.output.test.passed(test);
|
|
60
|
+
});
|
|
58
61
|
|
|
59
62
|
workers.on(event.test.skipped, (test) => {
|
|
60
|
-
skippedTestArr.push(test)
|
|
61
|
-
output.test.skipped(test)
|
|
62
|
-
})
|
|
63
|
+
skippedTestArr.push(test);
|
|
64
|
+
output.output.test.skipped(test);
|
|
65
|
+
});
|
|
63
66
|
|
|
64
67
|
workers.on(event.all.result, () => {
|
|
65
68
|
// expose test stats after all workers finished their execution
|
|
66
69
|
function addStepsToTest(test, stepArr) {
|
|
67
|
-
stepArr.test.steps.forEach(
|
|
70
|
+
stepArr.test.steps.forEach(step => {
|
|
68
71
|
if (test.steps.length === 0) {
|
|
69
|
-
test.steps.push(step)
|
|
72
|
+
test.steps.push(step);
|
|
70
73
|
}
|
|
71
|
-
})
|
|
74
|
+
});
|
|
72
75
|
}
|
|
73
76
|
|
|
74
|
-
stepArr.forEach(
|
|
75
|
-
passedTestArr.forEach(
|
|
77
|
+
stepArr.forEach(step => {
|
|
78
|
+
passedTestArr.forEach(test => {
|
|
76
79
|
if (step.test.title === test.title) {
|
|
77
|
-
addStepsToTest(test, step)
|
|
80
|
+
addStepsToTest(test, step);
|
|
78
81
|
}
|
|
79
|
-
})
|
|
82
|
+
});
|
|
80
83
|
|
|
81
|
-
failedTestArr.forEach(
|
|
84
|
+
failedTestArr.forEach(test => {
|
|
82
85
|
if (step.test.title === test.title) {
|
|
83
|
-
addStepsToTest(test, step)
|
|
86
|
+
addStepsToTest(test, step);
|
|
84
87
|
}
|
|
85
|
-
})
|
|
86
|
-
})
|
|
88
|
+
});
|
|
89
|
+
});
|
|
87
90
|
|
|
88
91
|
event.dispatcher.emit(event.workers.result, {
|
|
89
92
|
suites: suiteArr,
|
|
@@ -92,24 +95,23 @@ module.exports = async function (workerCount, selectedRuns, options) {
|
|
|
92
95
|
failed: failedTestArr,
|
|
93
96
|
skipped: skippedTestArr,
|
|
94
97
|
},
|
|
95
|
-
})
|
|
96
|
-
workers.printResults()
|
|
97
|
-
})
|
|
98
|
+
});
|
|
99
|
+
workers.printResults();
|
|
100
|
+
});
|
|
98
101
|
|
|
99
102
|
try {
|
|
100
|
-
if (options.verbose || options.debug) store.debugMode = true
|
|
103
|
+
if (options.verbose || options.debug) store.debugMode = true;
|
|
101
104
|
|
|
102
105
|
if (options.verbose) {
|
|
103
|
-
global.debugMode = true
|
|
104
|
-
|
|
105
|
-
await getMachineInfo()
|
|
106
|
+
global.debugMode = true;
|
|
107
|
+
await getMachineInfo();
|
|
106
108
|
}
|
|
107
|
-
await workers.bootstrapAll()
|
|
108
|
-
await workers.run()
|
|
109
|
+
await workers.bootstrapAll();
|
|
110
|
+
await workers.run();
|
|
109
111
|
} catch (err) {
|
|
110
|
-
output.error(err)
|
|
111
|
-
process.exit(1)
|
|
112
|
+
output.output.error(err);
|
|
113
|
+
process.exit(1);
|
|
112
114
|
} finally {
|
|
113
|
-
await workers.teardownAll()
|
|
115
|
+
await workers.teardownAll();
|
|
114
116
|
}
|
|
115
117
|
}
|
package/lib/command/run.js
CHANGED
|
@@ -1,46 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import importSync from 'import-sync';
|
|
2
|
+
import {
|
|
3
|
+
getConfig, printError, getTestRoot, createOutputDir,
|
|
4
|
+
} from './utils.js';
|
|
5
|
+
import Config from '../config.js';
|
|
6
|
+
import Codecept from '../codecept.js';
|
|
7
|
+
import { store } from '../store.js';
|
|
8
|
+
|
|
9
|
+
export default async function (test, options) {
|
|
7
10
|
// registering options globally to use in config
|
|
8
11
|
// Backward compatibility for --profile
|
|
9
12
|
// TODO: remove in CodeceptJS 4
|
|
10
|
-
process.profile = options.profile
|
|
13
|
+
process.profile = options.profile;
|
|
11
14
|
|
|
12
15
|
if (options.profile) {
|
|
13
|
-
process.env.profile = options.profile
|
|
16
|
+
process.env.profile = options.profile;
|
|
14
17
|
}
|
|
15
|
-
if (options.verbose || options.debug) store.debugMode = true
|
|
18
|
+
if (options.verbose || options.debug) store.debugMode = true;
|
|
19
|
+
|
|
20
|
+
const configFile = options.config;
|
|
16
21
|
|
|
17
|
-
|
|
22
|
+
let config = getConfig(configFile);
|
|
18
23
|
|
|
19
|
-
let config = getConfig(configFile)
|
|
20
24
|
if (options.override) {
|
|
21
|
-
config = Config.append(JSON.parse(options.override))
|
|
25
|
+
config = Config.append(JSON.parse(options.override));
|
|
22
26
|
}
|
|
23
|
-
const testRoot = getTestRoot(configFile)
|
|
24
|
-
createOutputDir(config, testRoot)
|
|
25
|
-
|
|
26
|
-
const codecept = new Codecept(config, options)
|
|
27
|
+
const testRoot = getTestRoot(configFile);
|
|
28
|
+
createOutputDir(config, testRoot);
|
|
27
29
|
|
|
30
|
+
const codecept = new Codecept(config, options);
|
|
28
31
|
try {
|
|
29
|
-
codecept.init(testRoot)
|
|
30
|
-
await codecept.bootstrap()
|
|
31
|
-
codecept.loadTests(test)
|
|
32
|
+
codecept.init(testRoot);
|
|
33
|
+
await codecept.bootstrap();
|
|
34
|
+
codecept.loadTests(test);
|
|
32
35
|
|
|
33
36
|
if (options.verbose) {
|
|
34
|
-
global.debugMode = true
|
|
35
|
-
const { getMachineInfo } =
|
|
36
|
-
await getMachineInfo()
|
|
37
|
+
global.debugMode = true;
|
|
38
|
+
const { getMachineInfo } = importSync('./info.js');
|
|
39
|
+
await getMachineInfo();
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
await codecept.run()
|
|
42
|
+
await codecept.run();
|
|
40
43
|
} catch (err) {
|
|
41
|
-
printError(err)
|
|
42
|
-
process.exitCode = 1
|
|
44
|
+
printError(err);
|
|
45
|
+
process.exitCode = 1;
|
|
43
46
|
} finally {
|
|
44
|
-
await codecept.teardown()
|
|
47
|
+
await codecept.teardown();
|
|
45
48
|
}
|
|
46
49
|
}
|
package/lib/command/utils.js
CHANGED
|
@@ -1,118 +1,103 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
module.exports.deepMerge = require('../utils').deepMerge
|
|
11
|
-
|
|
12
|
-
module.exports.getConfig = function (configFile) {
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import util from 'util';
|
|
4
|
+
import mkdirp from 'mkdirp';
|
|
5
|
+
import * as output from '../output.js';
|
|
6
|
+
import { fileExists, beautify } from '../utils.js';
|
|
7
|
+
import * as config from '../config.js';
|
|
8
|
+
|
|
9
|
+
export const getConfig = function (configFile) {
|
|
13
10
|
try {
|
|
14
|
-
return
|
|
11
|
+
return config.default.load(configFile);
|
|
15
12
|
} catch (err) {
|
|
16
|
-
fail(err.stack)
|
|
13
|
+
fail(err.stack);
|
|
17
14
|
}
|
|
18
|
-
}
|
|
15
|
+
};
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
export const readConfig = function (configFile) {
|
|
21
18
|
try {
|
|
22
|
-
const data = fs.readFileSync(configFile, 'utf8')
|
|
23
|
-
return data
|
|
19
|
+
const data = fs.readFileSync(configFile, 'utf8');
|
|
20
|
+
return data;
|
|
24
21
|
} catch (err) {
|
|
25
|
-
output.error(err)
|
|
22
|
+
output.output.error(err);
|
|
26
23
|
}
|
|
27
|
-
}
|
|
24
|
+
};
|
|
28
25
|
|
|
29
26
|
function getTestRoot(currentPath) {
|
|
30
|
-
if (!currentPath) currentPath = '.'
|
|
31
|
-
if (!path.isAbsolute(currentPath)) currentPath = path.join(process.cwd(), currentPath)
|
|
32
|
-
currentPath =
|
|
33
|
-
|
|
34
|
-
return currentPath
|
|
27
|
+
if (!currentPath) currentPath = '.';
|
|
28
|
+
if (!path.isAbsolute(currentPath)) currentPath = path.join(process.cwd(), currentPath);
|
|
29
|
+
currentPath = fs.lstatSync(currentPath).isDirectory() || !path.extname(currentPath) ? currentPath : path.dirname(currentPath);
|
|
30
|
+
return currentPath;
|
|
35
31
|
}
|
|
36
|
-
|
|
32
|
+
export { getTestRoot };
|
|
37
33
|
|
|
38
34
|
function fail(msg) {
|
|
39
|
-
output.error(msg)
|
|
40
|
-
process.exit(1)
|
|
35
|
+
output.output.error(msg);
|
|
36
|
+
process.exit(1);
|
|
41
37
|
}
|
|
42
38
|
|
|
43
|
-
|
|
39
|
+
export { fail };
|
|
44
40
|
|
|
45
|
-
function updateConfig(testsPath, config, extension) {
|
|
46
|
-
const configFile = path.join(testsPath, `codecept.conf.${extension}`)
|
|
41
|
+
function updateConfig(testsPath, config, key, extension = 'js') {
|
|
42
|
+
const configFile = path.join(testsPath, `codecept.conf.${extension}`);
|
|
47
43
|
if (!fileExists(configFile)) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
console.log(`${output.colors.bold.red(msg)}`)
|
|
51
|
-
console.log(
|
|
52
|
-
console.log()
|
|
53
|
-
console.log(config)
|
|
54
|
-
console.log()
|
|
55
|
-
return
|
|
44
|
+
console.log();
|
|
45
|
+
const msg = `codecept.conf.${extension} config can\'t be updated automatically`;
|
|
46
|
+
console.log(`${output.output.colors.bold.red(msg)}`);
|
|
47
|
+
console.log('Please update it manually:');
|
|
48
|
+
console.log();
|
|
49
|
+
console.log(`${key}: ${config[key]}`);
|
|
50
|
+
console.log();
|
|
51
|
+
return;
|
|
56
52
|
}
|
|
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')
|
|
53
|
+
console.log(`${output.output.colors.yellow('Updating configuration file...')}`);
|
|
54
|
+
return fs.writeFileSync(configFile, beautify(`exports.config = ${util.inspect(config, false, 4, false)}`), 'utf-8');
|
|
59
55
|
}
|
|
60
56
|
|
|
61
|
-
|
|
57
|
+
export { updateConfig };
|
|
62
58
|
|
|
63
59
|
function safeFileWrite(file, contents) {
|
|
64
60
|
if (fileExists(file)) {
|
|
65
|
-
output.error(`File ${file} already exist, skipping...`)
|
|
66
|
-
return false
|
|
61
|
+
output.output.error(`File ${file} already exist, skipping...`);
|
|
62
|
+
return false;
|
|
67
63
|
}
|
|
68
|
-
fs.writeFileSync(file, contents)
|
|
69
|
-
return true
|
|
64
|
+
fs.writeFileSync(file, contents);
|
|
65
|
+
return true;
|
|
70
66
|
}
|
|
71
67
|
|
|
72
|
-
|
|
68
|
+
export { safeFileWrite };
|
|
73
69
|
|
|
74
|
-
|
|
75
|
-
let oldStream
|
|
76
|
-
let buffer = ''
|
|
70
|
+
export const captureStream = (stream) => {
|
|
71
|
+
let oldStream;
|
|
72
|
+
let buffer = '';
|
|
77
73
|
|
|
78
74
|
return {
|
|
79
75
|
startCapture() {
|
|
80
|
-
buffer = ''
|
|
81
|
-
oldStream = stream.write.bind(stream)
|
|
82
|
-
stream.write =
|
|
76
|
+
buffer = '';
|
|
77
|
+
oldStream = stream.write.bind(stream);
|
|
78
|
+
stream.write = chunk => (buffer += chunk);
|
|
83
79
|
},
|
|
84
80
|
stopCapture() {
|
|
85
|
-
if (oldStream !== undefined) stream.write = oldStream
|
|
81
|
+
if (oldStream !== undefined) stream.write = oldStream;
|
|
86
82
|
},
|
|
87
83
|
getData: () => buffer,
|
|
88
|
-
}
|
|
89
|
-
}
|
|
84
|
+
};
|
|
85
|
+
};
|
|
90
86
|
|
|
91
|
-
|
|
92
|
-
output.print('')
|
|
93
|
-
output.error(err.message)
|
|
94
|
-
output.print('')
|
|
95
|
-
output.print(output.colors.grey(err.stack.replace(err.message, '')))
|
|
96
|
-
}
|
|
87
|
+
export const printError = (err) => {
|
|
88
|
+
output.print('');
|
|
89
|
+
output.output.error(err.message);
|
|
90
|
+
output.print('');
|
|
91
|
+
output.print(output.output.colors.grey(err.stack.replace(err.message, '')));
|
|
92
|
+
};
|
|
97
93
|
|
|
98
|
-
|
|
99
|
-
let outputDir
|
|
100
|
-
if (path.isAbsolute(config.output)) outputDir = config.output
|
|
101
|
-
else outputDir = path.join(testRoot, config.output)
|
|
94
|
+
export const createOutputDir = (config, testRoot) => {
|
|
95
|
+
let outputDir;
|
|
96
|
+
if (path.isAbsolute(config.output)) outputDir = config.output;
|
|
97
|
+
else outputDir = path.join(testRoot, config.output);
|
|
102
98
|
|
|
103
99
|
if (!fileExists(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
|
-
}
|
|
100
|
+
output.print(`creating output directory: ${outputDir}`);
|
|
101
|
+
mkdirp.sync(outputDir);
|
|
116
102
|
}
|
|
117
|
-
|
|
118
|
-
}
|
|
103
|
+
};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import tty from 'tty';
|
|
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';
|
|
2
8
|
|
|
3
9
|
if (!tty.getWindowSize) {
|
|
4
10
|
// this is really old method, long removed from Node, but Mocha
|
|
@@ -7,19 +13,13 @@ if (!tty.getWindowSize) {
|
|
|
7
13
|
tty.getWindowSize = () => [40, 80];
|
|
8
14
|
}
|
|
9
15
|
|
|
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
|
-
const Codecept =
|
|
22
|
+
// const Codecept = importSync(process.env.CODECEPT_CLASS_PATH || '../../codecept.js');
|
|
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,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
isFile,
|
|
6
|
-
|
|
7
|
-
deepClone,
|
|
8
|
-
} = require('./utils');
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import importSync from 'import-sync';
|
|
4
|
+
import {
|
|
5
|
+
fileExists, isFile, deepMerge, deepClone,
|
|
6
|
+
} from './utils.js';
|
|
9
7
|
|
|
10
8
|
const defaultConfig = {
|
|
11
9
|
output: './_output',
|
|
@@ -142,7 +140,7 @@ class Config {
|
|
|
142
140
|
}
|
|
143
141
|
}
|
|
144
142
|
|
|
145
|
-
|
|
143
|
+
export default Config;
|
|
146
144
|
|
|
147
145
|
function loadConfigFile(configFile) {
|
|
148
146
|
const extensionName = path.extname(configFile);
|
|
@@ -157,7 +155,8 @@ function loadConfigFile(configFile) {
|
|
|
157
155
|
|
|
158
156
|
// .conf.js config file
|
|
159
157
|
if (extensionName === '.js' || extensionName === '.ts' || extensionName === '.cjs') {
|
|
160
|
-
|
|
158
|
+
const { config } = importSync(configFile);
|
|
159
|
+
return Config.create(config);
|
|
161
160
|
}
|
|
162
161
|
|
|
163
162
|
// json config provided
|