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