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.
Files changed (151) hide show
  1. package/bin/codecept.js +81 -84
  2. package/lib/actor.js +13 -13
  3. package/lib/ai.js +13 -10
  4. package/lib/assert/empty.js +21 -20
  5. package/lib/assert/equal.js +39 -37
  6. package/lib/assert/error.js +14 -14
  7. package/lib/assert/include.js +47 -46
  8. package/lib/assert/throws.js +11 -13
  9. package/lib/assert/truth.js +22 -19
  10. package/lib/assert.js +2 -4
  11. package/lib/cli.js +49 -57
  12. package/lib/codecept.js +155 -142
  13. package/lib/colorUtils.js +3 -3
  14. package/lib/command/configMigrate.js +52 -58
  15. package/lib/command/definitions.js +89 -88
  16. package/lib/command/dryRun.js +68 -71
  17. package/lib/command/generate.js +188 -197
  18. package/lib/command/gherkin/init.js +16 -27
  19. package/lib/command/gherkin/snippets.js +20 -20
  20. package/lib/command/gherkin/steps.js +8 -8
  21. package/lib/command/info.js +38 -40
  22. package/lib/command/init.js +288 -290
  23. package/lib/command/interactive.js +32 -32
  24. package/lib/command/list.js +26 -26
  25. package/lib/command/run-multiple/chunk.js +5 -5
  26. package/lib/command/run-multiple/collection.js +3 -3
  27. package/lib/command/run-multiple/run.js +2 -6
  28. package/lib/command/run-multiple.js +93 -113
  29. package/lib/command/run-rerun.js +25 -20
  30. package/lib/command/run-workers.js +66 -64
  31. package/lib/command/run.js +29 -26
  32. package/lib/command/utils.js +65 -80
  33. package/lib/command/workers/runTests.js +10 -10
  34. package/lib/config.js +9 -10
  35. package/lib/container.js +48 -40
  36. package/lib/data/context.js +59 -60
  37. package/lib/data/dataScenarioConfig.js +47 -47
  38. package/lib/data/dataTableArgument.js +29 -29
  39. package/lib/data/table.js +20 -26
  40. package/lib/dirname.js +5 -0
  41. package/lib/event.js +167 -163
  42. package/lib/heal.js +17 -13
  43. package/lib/helper/AI.js +41 -130
  44. package/lib/helper/ApiDataFactory.js +69 -73
  45. package/lib/helper/Appium.js +381 -412
  46. package/lib/helper/Expect.js +425 -0
  47. package/lib/helper/ExpectHelper.js +48 -40
  48. package/lib/helper/FileSystem.js +79 -80
  49. package/lib/helper/GraphQL.js +43 -44
  50. package/lib/helper/GraphQLDataFactory.js +50 -50
  51. package/lib/helper/JSONResponse.js +62 -65
  52. package/lib/helper/Mochawesome.js +28 -28
  53. package/lib/helper/MockServer.js +14 -12
  54. package/lib/helper/Nightmare.js +566 -662
  55. package/lib/helper/Playwright.js +1216 -1361
  56. package/lib/helper/Protractor.js +627 -663
  57. package/lib/helper/Puppeteer.js +1128 -1231
  58. package/lib/helper/REST.js +68 -159
  59. package/lib/helper/SoftExpectHelper.js +2 -2
  60. package/lib/helper/TestCafe.js +484 -490
  61. package/lib/helper/WebDriver.js +1156 -1297
  62. package/lib/helper/clientscripts/PollyWebDriverExt.js +1 -1
  63. package/lib/helper/errors/ConnectionRefused.js +1 -1
  64. package/lib/helper/errors/ElementAssertion.js +2 -2
  65. package/lib/helper/errors/ElementNotFound.js +2 -2
  66. package/lib/helper/errors/RemoteBrowserConnectionRefused.js +1 -1
  67. package/lib/helper/extras/Console.js +1 -1
  68. package/lib/helper/extras/PlaywrightPropEngine.js +2 -2
  69. package/lib/helper/extras/PlaywrightReactVueLocator.js +1 -1
  70. package/lib/helper/extras/PlaywrightRestartOpts.js +18 -21
  71. package/lib/helper/extras/Popup.js +1 -1
  72. package/lib/helper/extras/React.js +3 -3
  73. package/lib/helper/network/actions.js +7 -14
  74. package/lib/helper/network/utils.js +2 -3
  75. package/lib/helper/scripts/blurElement.js +1 -1
  76. package/lib/helper/scripts/focusElement.js +1 -1
  77. package/lib/helper/scripts/highlightElement.js +1 -1
  78. package/lib/helper/scripts/isElementClickable.js +1 -1
  79. package/lib/helper/testcafe/testControllerHolder.js +1 -1
  80. package/lib/helper/testcafe/testcafe-utils.js +7 -6
  81. package/lib/helper.js +3 -1
  82. package/lib/history.js +5 -6
  83. package/lib/hooks.js +6 -6
  84. package/lib/html.js +7 -7
  85. package/lib/index.js +41 -25
  86. package/lib/interfaces/bdd.js +64 -47
  87. package/lib/interfaces/featureConfig.js +19 -19
  88. package/lib/interfaces/gherkin.js +118 -124
  89. package/lib/interfaces/scenarioConfig.js +29 -29
  90. package/lib/listener/artifacts.js +9 -9
  91. package/lib/listener/config.js +24 -24
  92. package/lib/listener/exit.js +12 -12
  93. package/lib/listener/helpers.js +42 -42
  94. package/lib/listener/mocha.js +11 -11
  95. package/lib/listener/retry.js +30 -32
  96. package/lib/listener/steps.js +53 -50
  97. package/lib/listener/timeout.js +54 -54
  98. package/lib/locator.js +10 -6
  99. package/lib/mochaFactory.js +15 -18
  100. package/lib/output.js +10 -6
  101. package/lib/parser.js +12 -15
  102. package/lib/pause.js +33 -40
  103. package/lib/plugin/allure.js +15 -15
  104. package/lib/plugin/autoDelay.js +37 -29
  105. package/lib/plugin/autoLogin.js +65 -70
  106. package/lib/plugin/commentStep.js +18 -18
  107. package/lib/plugin/coverage.js +67 -115
  108. package/lib/plugin/customLocator.js +20 -21
  109. package/lib/plugin/debugErrors.js +24 -24
  110. package/lib/plugin/eachElement.js +38 -38
  111. package/lib/plugin/fakerTransform.js +6 -6
  112. package/lib/plugin/heal.js +108 -67
  113. package/lib/plugin/pauseOnFail.js +11 -11
  114. package/lib/plugin/retryFailedStep.js +39 -32
  115. package/lib/plugin/retryTo.js +40 -46
  116. package/lib/plugin/screenshotOnFail.js +87 -109
  117. package/lib/plugin/selenoid.js +118 -131
  118. package/lib/plugin/standardActingHelpers.js +8 -2
  119. package/lib/plugin/stepByStepReport.js +91 -110
  120. package/lib/plugin/stepTimeout.js +23 -24
  121. package/lib/plugin/subtitles.js +35 -34
  122. package/lib/plugin/tryTo.js +30 -40
  123. package/lib/plugin/wdio.js +75 -78
  124. package/lib/recorder.js +17 -14
  125. package/lib/rerun.js +10 -11
  126. package/lib/scenario.js +23 -25
  127. package/lib/secret.js +2 -4
  128. package/lib/session.js +10 -10
  129. package/lib/step.js +9 -12
  130. package/lib/store.js +3 -2
  131. package/lib/transform.js +1 -1
  132. package/lib/translation.js +8 -7
  133. package/lib/ui.js +14 -12
  134. package/lib/utils.js +72 -70
  135. package/lib/within.js +10 -10
  136. package/lib/workerStorage.js +25 -27
  137. package/lib/workers.js +32 -29
  138. package/package.json +53 -51
  139. package/translations/de-DE.js +1 -1
  140. package/translations/fr-FR.js +1 -1
  141. package/translations/index.js +13 -9
  142. package/translations/it-IT.js +1 -1
  143. package/translations/ja-JP.js +1 -1
  144. package/translations/pl-PL.js +1 -1
  145. package/translations/pt-BR.js +1 -1
  146. package/translations/ru-RU.js +1 -1
  147. package/translations/zh-CN.js +1 -1
  148. package/translations/zh-TW.js +1 -1
  149. package/typings/index.d.ts +65 -415
  150. package/typings/promiseBasedTypes.d.ts +32 -0
  151. 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
- 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
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
- output.print(`CodeceptJS v${require('../codecept').version()} ${output.standWithUkraine()}`)
31
- output.print(`Running tests in ${output.styles.bold(numberOfWorkers)} workers...`)
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((step) => {
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((step) => {
75
- passedTestArr.forEach((test) => {
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((test) => {
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
- const { getMachineInfo } = require('./info')
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
  }
@@ -1,46 +1,49 @@
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) {
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
- const configFile = options.config
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 } = require('./info')
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
  }
@@ -1,118 +1,103 @@
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) {
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 require('../config').load(configFile)
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
- module.exports.readConfig = function (configFile) {
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
- fs.lstatSync(currentPath).isDirectory() || !path.extname(currentPath) ? currentPath : path.dirname(currentPath)
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
- module.exports.getTestRoot = getTestRoot
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
- module.exports.fail = fail
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
- 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
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
- module.exports.updateConfig = updateConfig
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
- module.exports.safeFileWrite = safeFileWrite
68
+ export { safeFileWrite };
73
69
 
74
- module.exports.captureStream = (stream) => {
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 = (chunk) => (buffer += chunk)
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
- 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
- }
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
- 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)
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
- return null
118
- }
103
+ };
@@ -1,4 +1,10 @@
1
- const tty = require('tty');
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 = require(process.env.CODECEPT_CLASS_PATH || '../../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 = container.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
- container.append({ support: eventData.data });
290
+ Container.append({ support: eventData.data });
291
291
  });
292
292
  }
package/lib/config.js CHANGED
@@ -1,11 +1,9 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const {
4
- fileExists,
5
- isFile,
6
- deepMerge,
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
- module.exports = Config;
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
- return Config.create(require(configFile).config);
158
+ const { config } = importSync(configFile);
159
+ return Config.create(config);
161
160
  }
162
161
 
163
162
  // json config provided