codeceptjs 4.0.0-beta.4 → 4.0.0-beta.6.esm-aria

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 (188) hide show
  1. package/README.md +89 -119
  2. package/bin/codecept.js +53 -54
  3. package/docs/webapi/clearCookie.mustache +1 -1
  4. package/lib/actor.js +70 -102
  5. package/lib/ai.js +131 -121
  6. package/lib/assert/empty.js +11 -12
  7. package/lib/assert/equal.js +16 -21
  8. package/lib/assert/error.js +2 -2
  9. package/lib/assert/include.js +11 -15
  10. package/lib/assert/throws.js +3 -5
  11. package/lib/assert/truth.js +10 -7
  12. package/lib/assert.js +18 -18
  13. package/lib/codecept.js +112 -101
  14. package/lib/colorUtils.js +48 -50
  15. package/lib/command/check.js +206 -0
  16. package/lib/command/configMigrate.js +13 -14
  17. package/lib/command/definitions.js +24 -36
  18. package/lib/command/dryRun.js +16 -16
  19. package/lib/command/generate.js +38 -39
  20. package/lib/command/gherkin/init.js +36 -38
  21. package/lib/command/gherkin/snippets.js +76 -74
  22. package/lib/command/gherkin/steps.js +21 -18
  23. package/lib/command/info.js +49 -15
  24. package/lib/command/init.js +41 -37
  25. package/lib/command/interactive.js +22 -13
  26. package/lib/command/list.js +11 -10
  27. package/lib/command/run-multiple/chunk.js +50 -47
  28. package/lib/command/run-multiple/collection.js +5 -5
  29. package/lib/command/run-multiple/run.js +3 -3
  30. package/lib/command/run-multiple.js +27 -47
  31. package/lib/command/run-rerun.js +6 -7
  32. package/lib/command/run-workers.js +15 -66
  33. package/lib/command/run.js +8 -8
  34. package/lib/command/utils.js +22 -21
  35. package/lib/command/workers/runTests.js +131 -241
  36. package/lib/config.js +111 -49
  37. package/lib/container.js +589 -244
  38. package/lib/data/context.js +16 -18
  39. package/lib/data/dataScenarioConfig.js +9 -9
  40. package/lib/data/dataTableArgument.js +7 -7
  41. package/lib/data/table.js +6 -12
  42. package/lib/effects.js +307 -0
  43. package/lib/els.js +160 -0
  44. package/lib/event.js +24 -19
  45. package/lib/globals.js +141 -0
  46. package/lib/heal.js +89 -81
  47. package/lib/helper/AI.js +3 -2
  48. package/lib/helper/ApiDataFactory.js +19 -19
  49. package/lib/helper/Appium.js +47 -51
  50. package/lib/helper/FileSystem.js +35 -15
  51. package/lib/helper/GraphQL.js +1 -1
  52. package/lib/helper/GraphQLDataFactory.js +4 -4
  53. package/lib/helper/JSONResponse.js +72 -45
  54. package/lib/helper/Mochawesome.js +14 -11
  55. package/lib/helper/Playwright.js +832 -434
  56. package/lib/helper/Puppeteer.js +393 -292
  57. package/lib/helper/REST.js +32 -27
  58. package/lib/helper/WebDriver.js +320 -219
  59. package/lib/helper/errors/ConnectionRefused.js +6 -6
  60. package/lib/helper/errors/ElementAssertion.js +11 -16
  61. package/lib/helper/errors/ElementNotFound.js +5 -9
  62. package/lib/helper/errors/RemoteBrowserConnectionRefused.js +5 -5
  63. package/lib/helper/extras/Console.js +11 -11
  64. package/lib/helper/extras/PlaywrightLocator.js +110 -0
  65. package/lib/helper/extras/PlaywrightPropEngine.js +18 -18
  66. package/lib/helper/extras/PlaywrightRestartOpts.js +23 -23
  67. package/lib/helper/extras/Popup.js +22 -22
  68. package/lib/helper/extras/React.js +29 -30
  69. package/lib/helper/network/actions.js +33 -48
  70. package/lib/helper/network/utils.js +76 -83
  71. package/lib/helper/scripts/blurElement.js +6 -6
  72. package/lib/helper/scripts/focusElement.js +6 -6
  73. package/lib/helper/scripts/highlightElement.js +9 -9
  74. package/lib/helper/scripts/isElementClickable.js +34 -34
  75. package/lib/helper.js +2 -1
  76. package/lib/history.js +23 -20
  77. package/lib/hooks.js +10 -10
  78. package/lib/html.js +90 -100
  79. package/lib/index.js +48 -21
  80. package/lib/listener/config.js +8 -9
  81. package/lib/listener/emptyRun.js +54 -0
  82. package/lib/listener/exit.js +10 -12
  83. package/lib/listener/{retry.js → globalRetry.js} +10 -10
  84. package/lib/listener/globalTimeout.js +166 -0
  85. package/lib/listener/helpers.js +43 -24
  86. package/lib/listener/mocha.js +4 -5
  87. package/lib/listener/result.js +11 -0
  88. package/lib/listener/steps.js +26 -23
  89. package/lib/listener/store.js +20 -0
  90. package/lib/locator.js +213 -192
  91. package/lib/mocha/asyncWrapper.js +264 -0
  92. package/lib/mocha/bdd.js +167 -0
  93. package/lib/mocha/cli.js +341 -0
  94. package/lib/mocha/factory.js +160 -0
  95. package/lib/{interfaces → mocha}/featureConfig.js +33 -13
  96. package/lib/{interfaces → mocha}/gherkin.js +75 -45
  97. package/lib/mocha/hooks.js +121 -0
  98. package/lib/mocha/index.js +21 -0
  99. package/lib/mocha/inject.js +46 -0
  100. package/lib/{interfaces → mocha}/scenarioConfig.js +32 -8
  101. package/lib/mocha/suite.js +89 -0
  102. package/lib/mocha/test.js +178 -0
  103. package/lib/mocha/types.d.ts +42 -0
  104. package/lib/mocha/ui.js +229 -0
  105. package/lib/output.js +86 -64
  106. package/lib/parser.js +44 -44
  107. package/lib/pause.js +160 -139
  108. package/lib/plugin/analyze.js +403 -0
  109. package/lib/plugin/{autoLogin.js → auth.js} +137 -43
  110. package/lib/plugin/autoDelay.js +19 -15
  111. package/lib/plugin/coverage.js +22 -27
  112. package/lib/plugin/customLocator.js +5 -5
  113. package/lib/plugin/customReporter.js +53 -0
  114. package/lib/plugin/heal.js +49 -17
  115. package/lib/plugin/pageInfo.js +140 -0
  116. package/lib/plugin/pauseOnFail.js +4 -3
  117. package/lib/plugin/retryFailedStep.js +60 -19
  118. package/lib/plugin/screenshotOnFail.js +80 -83
  119. package/lib/plugin/stepByStepReport.js +70 -31
  120. package/lib/plugin/stepTimeout.js +7 -13
  121. package/lib/plugin/subtitles.js +10 -9
  122. package/lib/recorder.js +167 -126
  123. package/lib/rerun.js +94 -50
  124. package/lib/result.js +161 -0
  125. package/lib/secret.js +18 -17
  126. package/lib/session.js +95 -89
  127. package/lib/step/base.js +239 -0
  128. package/lib/step/comment.js +10 -0
  129. package/lib/step/config.js +50 -0
  130. package/lib/step/func.js +46 -0
  131. package/lib/step/helper.js +50 -0
  132. package/lib/step/meta.js +99 -0
  133. package/lib/step/record.js +74 -0
  134. package/lib/step/retry.js +11 -0
  135. package/lib/step/section.js +55 -0
  136. package/lib/step.js +18 -332
  137. package/lib/steps.js +54 -0
  138. package/lib/store.js +37 -5
  139. package/lib/template/heal.js +2 -11
  140. package/lib/timeout.js +60 -0
  141. package/lib/transform.js +8 -8
  142. package/lib/translation.js +32 -18
  143. package/lib/utils.js +354 -250
  144. package/lib/workerStorage.js +16 -16
  145. package/lib/workers.js +366 -282
  146. package/package.json +107 -95
  147. package/translations/de-DE.js +5 -4
  148. package/translations/fr-FR.js +5 -4
  149. package/translations/index.js +23 -9
  150. package/translations/it-IT.js +5 -4
  151. package/translations/ja-JP.js +5 -4
  152. package/translations/nl-NL.js +76 -0
  153. package/translations/pl-PL.js +5 -4
  154. package/translations/pt-BR.js +5 -4
  155. package/translations/ru-RU.js +5 -4
  156. package/translations/utils.js +18 -0
  157. package/translations/zh-CN.js +5 -4
  158. package/translations/zh-TW.js +5 -4
  159. package/typings/index.d.ts +177 -186
  160. package/typings/promiseBasedTypes.d.ts +3573 -5941
  161. package/typings/types.d.ts +4042 -6370
  162. package/lib/cli.js +0 -256
  163. package/lib/helper/ExpectHelper.js +0 -391
  164. package/lib/helper/Nightmare.js +0 -1504
  165. package/lib/helper/Protractor.js +0 -1863
  166. package/lib/helper/SoftExpectHelper.js +0 -381
  167. package/lib/helper/TestCafe.js +0 -1414
  168. package/lib/helper/clientscripts/nightmare.js +0 -213
  169. package/lib/helper/extras/PlaywrightReactVueLocator.js +0 -43
  170. package/lib/helper/testcafe/testControllerHolder.js +0 -42
  171. package/lib/helper/testcafe/testcafe-utils.js +0 -62
  172. package/lib/interfaces/bdd.js +0 -81
  173. package/lib/listener/artifacts.js +0 -19
  174. package/lib/listener/timeout.js +0 -109
  175. package/lib/mochaFactory.js +0 -113
  176. package/lib/plugin/allure.js +0 -15
  177. package/lib/plugin/commentStep.js +0 -136
  178. package/lib/plugin/debugErrors.js +0 -67
  179. package/lib/plugin/eachElement.js +0 -127
  180. package/lib/plugin/fakerTransform.js +0 -49
  181. package/lib/plugin/retryTo.js +0 -127
  182. package/lib/plugin/selenoid.js +0 -384
  183. package/lib/plugin/standardActingHelpers.js +0 -3
  184. package/lib/plugin/tryTo.js +0 -115
  185. package/lib/plugin/wdio.js +0 -249
  186. package/lib/scenario.js +0 -224
  187. package/lib/ui.js +0 -236
  188. package/lib/within.js +0 -70
@@ -1,30 +1,20 @@
1
- const { fork } = require('child_process')
2
- const path = require('path')
3
- const crypto = require('crypto')
4
-
5
- const runHook = require('../hooks')
6
- const event = require('../event')
7
- const collection = require('./run-multiple/collection')
8
- const { clearString, replaceValueDeep } = require('../utils')
9
- const { getConfig, getTestRoot, fail } = require('./utils')
10
-
1
+ import { fork } from 'child_process'
2
+ import path from 'path'
3
+ import crypto from 'crypto'
4
+ import { fileURLToPath } from 'url'
5
+
6
+ import runHook from '../hooks.js'
7
+ import event from '../event.js'
8
+ import { createRuns } from './run-multiple/collection.js'
9
+ import { clearString, replaceValueDeep } from '../utils.js'
10
+ import { getConfig, getTestRoot, fail } from './utils.js'
11
+
12
+ const __filename = fileURLToPath(import.meta.url)
13
+ const __dirname = path.dirname(__filename)
11
14
  const runner = path.join(__dirname, '/../../bin/codecept')
12
15
  let config
13
16
  const childOpts = {}
14
- const copyOptions = [
15
- 'override',
16
- 'steps',
17
- 'reporter',
18
- 'verbose',
19
- 'config',
20
- 'reporter-options',
21
- 'grep',
22
- 'fgrep',
23
- 'invert',
24
- 'debug',
25
- 'plugins',
26
- 'colors',
27
- ]
17
+ const copyOptions = ['override', 'steps', 'reporter', 'verbose', 'config', 'reporter-options', 'grep', 'fgrep', 'invert', 'debug', 'plugins', 'colors']
28
18
  let overrides = {}
29
19
 
30
20
  // codeceptjs run-multiple smoke:chrome regression:firefox - will launch smoke run in chrome and regression in firefox
@@ -37,7 +27,7 @@ let subprocessCount = 0
37
27
  let totalSubprocessCount = 0
38
28
  let processesDone
39
29
 
40
- module.exports = async function (selectedRuns, options) {
30
+ export default async function (selectedRuns, options) {
41
31
  // registering options globally to use in config
42
32
  if (options.profile) {
43
33
  process.env.profile = options.profile
@@ -49,8 +39,8 @@ module.exports = async function (selectedRuns, options) {
49
39
 
50
40
  // copy opts to run
51
41
  Object.keys(options)
52
- .filter((key) => copyOptions.indexOf(key) > -1)
53
- .forEach((key) => {
42
+ .filter(key => copyOptions.indexOf(key) > -1)
43
+ .forEach(key => {
54
44
  childOpts[key] = options[key]
55
45
  })
56
46
 
@@ -62,7 +52,7 @@ module.exports = async function (selectedRuns, options) {
62
52
  }
63
53
 
64
54
  config = {
65
- ...getConfig(configFile),
55
+ ...(await getConfig(configFile)),
66
56
  ...overrides,
67
57
  }
68
58
 
@@ -96,12 +86,12 @@ module.exports = async function (selectedRuns, options) {
96
86
  config.gherkin.features = ''
97
87
  }
98
88
 
99
- const childProcessesPromise = new Promise((resolve) => {
89
+ const childProcessesPromise = new Promise(resolve => {
100
90
  processesDone = resolve
101
91
  })
102
92
 
103
93
  const runsToExecute = []
104
- collection.createRuns(selectedRuns, config).forEach((run) => {
94
+ createRuns(selectedRuns, config).forEach(run => {
105
95
  const runName = run.getOriginalName() || run.getName()
106
96
  const runConfig = run.getConfig()
107
97
  runsToExecute.push(executeRun(runName, runConfig))
@@ -113,7 +103,7 @@ module.exports = async function (selectedRuns, options) {
113
103
 
114
104
  // Execute all forks
115
105
  totalSubprocessCount = runsToExecute.length
116
- runsToExecute.forEach((runToExecute) => runToExecute.call(this))
106
+ runsToExecute.forEach(runToExecute => runToExecute.call(this))
117
107
 
118
108
  return childProcessesPromise.then(async () => {
119
109
  // fire hook
@@ -149,11 +139,7 @@ function executeRun(runName, runConfig) {
149
139
  // tweaking default output directories and for mochawesome
150
140
  overriddenConfig = replaceValueDeep(overriddenConfig, 'output', path.join(config.output, outputDir))
151
141
  overriddenConfig = replaceValueDeep(overriddenConfig, 'reportDir', path.join(config.output, outputDir))
152
- overriddenConfig = replaceValueDeep(
153
- overriddenConfig,
154
- 'mochaFile',
155
- path.join(config.output, outputDir, `${browserName}_report.xml`),
156
- )
142
+ overriddenConfig = replaceValueDeep(overriddenConfig, 'mochaFile', path.join(config.output, outputDir, `${browserName}_report.xml`))
157
143
 
158
144
  // override tests configuration
159
145
  if (overriddenConfig.tests) {
@@ -165,15 +151,9 @@ function executeRun(runName, runConfig) {
165
151
  }
166
152
 
167
153
  // override grep param and collect all params
168
- const params = [
169
- 'run',
170
- '--child',
171
- `${runId++}.${runName}:${browserName}`,
172
- '--override',
173
- JSON.stringify(overriddenConfig),
174
- ]
175
-
176
- Object.keys(childOpts).forEach((key) => {
154
+ const params = ['run', '--child', `${runId++}.${runName}:${browserName}`, '--override', JSON.stringify(overriddenConfig)]
155
+
156
+ Object.keys(childOpts).forEach(key => {
177
157
  params.push(`--${key}`)
178
158
  if (childOpts[key] !== true) params.push(childOpts[key])
179
159
  })
@@ -183,7 +163,7 @@ function executeRun(runName, runConfig) {
183
163
  params.push(runConfig.grep)
184
164
  }
185
165
 
186
- const onProcessEnd = (errorCode) => {
166
+ const onProcessEnd = errorCode => {
187
167
  if (errorCode !== 0) {
188
168
  process.exitCode = errorCode
189
169
  }
@@ -197,7 +177,7 @@ function executeRun(runName, runConfig) {
197
177
  // Return function of fork for later execution
198
178
  return () =>
199
179
  fork(runner, params, { stdio: [0, 1, 2, 'ipc'] })
200
- .on('exit', (code) => {
180
+ .on('exit', code => {
201
181
  return onProcessEnd(code)
202
182
  })
203
183
  .on('error', () => {
@@ -1,16 +1,15 @@
1
- const { getConfig, getTestRoot } = require('./utils')
2
- const { printError, createOutputDir } = require('./utils')
3
- const Config = require('../config')
4
- const Codecept = require('../rerun')
1
+ import { getConfig, getTestRoot, printError, createOutputDir } from './utils.js'
2
+ import Config from '../config.js'
3
+ import Codecept from '../rerun.js'
5
4
 
6
- module.exports = async function (test, options) {
5
+ export default async function (test, options) {
7
6
  // registering options globally to use in config
8
7
  // Backward compatibility for --profile
9
8
  process.profile = options.profile
10
9
  process.env.profile = options.profile
11
10
  const configFile = options.config
12
11
 
13
- let config = getConfig(configFile)
12
+ let config = await getConfig(configFile)
14
13
  if (options.override) {
15
14
  config = Config.append(JSON.parse(options.override))
16
15
  }
@@ -20,7 +19,7 @@ module.exports = async function (test, options) {
20
19
  const codecept = new Codecept(config, options)
21
20
 
22
21
  try {
23
- codecept.init(testRoot)
22
+ await codecept.init(testRoot)
24
23
 
25
24
  await codecept.bootstrap()
26
25
  codecept.loadTests(test)
@@ -1,19 +1,15 @@
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) {
2
+ import { tryOrDefault } from '../utils.js'
3
+ import output from '../output.js'
4
+ import store from '../store.js'
5
+ import event from '../event.js'
6
+ import Workers from '../workers.js'
7
+ import Codecept from '../codecept.js'
8
+ import { getMachineInfo } from './info.js'
9
+
10
+ export default async function (workerCount, selectedRuns, options) {
9
11
  process.env.profile = options.profile
10
12
 
11
- const suiteArr = []
12
- const passedTestArr = []
13
- const failedTestArr = []
14
- const skippedTestArr = []
15
- const stepArr = []
16
-
17
13
  const { config: testConfig, override = '' } = options
18
14
  const overrideConfigs = tryOrDefault(() => JSON.parse(override), {})
19
15
  const by = options.suites ? 'suite' : 'test'
@@ -27,72 +23,27 @@ module.exports = async function (workerCount, selectedRuns, options) {
27
23
 
28
24
  const numberOfWorkers = parseInt(workerCount, 10)
29
25
 
30
- output.print(`CodeceptJS v${require('../codecept').version()} ${output.standWithUkraine()}`)
26
+ output.print(`CodeceptJS v${Codecept.version()} ${output.standWithUkraine()}`)
31
27
  output.print(`Running tests in ${output.styles.bold(numberOfWorkers)} workers...`)
32
28
  output.print()
29
+ store.hasWorkers = true
33
30
 
34
31
  const workers = new Workers(numberOfWorkers, config)
35
32
  workers.overrideConfig(overrideConfigs)
36
33
 
37
- workers.on(event.suite.before, (suite) => {
38
- suiteArr.push(suite)
39
- })
40
-
41
- workers.on(event.step.passed, (step) => {
42
- stepArr.push(step)
43
- })
44
-
45
- workers.on(event.step.failed, (step) => {
46
- stepArr.push(step)
47
- })
48
-
49
- workers.on(event.test.failed, (test) => {
50
- failedTestArr.push(test)
34
+ workers.on(event.test.failed, test => {
51
35
  output.test.failed(test)
52
36
  })
53
37
 
54
- workers.on(event.test.passed, (test) => {
55
- passedTestArr.push(test)
38
+ workers.on(event.test.passed, test => {
56
39
  output.test.passed(test)
57
40
  })
58
41
 
59
- workers.on(event.test.skipped, (test) => {
60
- skippedTestArr.push(test)
42
+ workers.on(event.test.skipped, test => {
61
43
  output.test.skipped(test)
62
44
  })
63
45
 
64
- workers.on(event.all.result, () => {
65
- // expose test stats after all workers finished their execution
66
- function addStepsToTest(test, stepArr) {
67
- stepArr.test.steps.forEach((step) => {
68
- if (test.steps.length === 0) {
69
- test.steps.push(step)
70
- }
71
- })
72
- }
73
-
74
- stepArr.forEach((step) => {
75
- passedTestArr.forEach((test) => {
76
- if (step.test.title === test.title) {
77
- addStepsToTest(test, step)
78
- }
79
- })
80
-
81
- failedTestArr.forEach((test) => {
82
- if (step.test.title === test.title) {
83
- addStepsToTest(test, step)
84
- }
85
- })
86
- })
87
-
88
- event.dispatcher.emit(event.workers.result, {
89
- suites: suiteArr,
90
- tests: {
91
- passed: passedTestArr,
92
- failed: failedTestArr,
93
- skipped: skippedTestArr,
94
- },
95
- })
46
+ workers.on(event.all.result, result => {
96
47
  workers.printResults()
97
48
  })
98
49
 
@@ -100,8 +51,6 @@ module.exports = async function (workerCount, selectedRuns, options) {
100
51
  if (options.verbose || options.debug) store.debugMode = true
101
52
 
102
53
  if (options.verbose) {
103
- global.debugMode = true
104
- const { getMachineInfo } = require('./info')
105
54
  await getMachineInfo()
106
55
  }
107
56
  await workers.bootstrapAll()
@@ -1,9 +1,9 @@
1
- const { getConfig, printError, getTestRoot, createOutputDir } = require('./utils')
2
- const Config = require('../config')
3
- const store = require('../store')
4
- const Codecept = require('../codecept')
1
+ import { getConfig, printError, getTestRoot, createOutputDir } from './utils.js'
2
+ import Config from '../config.js'
3
+ import store from '../store.js'
4
+ import Codecept from '../codecept.js'
5
5
 
6
- module.exports = async function (test, options) {
6
+ export default async function (test, options) {
7
7
  // registering options globally to use in config
8
8
  // Backward compatibility for --profile
9
9
  // TODO: remove in CodeceptJS 4
@@ -16,7 +16,7 @@ module.exports = async function (test, options) {
16
16
 
17
17
  const configFile = options.config
18
18
 
19
- let config = getConfig(configFile)
19
+ let config = await getConfig(configFile)
20
20
  if (options.override) {
21
21
  config = Config.append(JSON.parse(options.override))
22
22
  }
@@ -26,13 +26,13 @@ module.exports = async function (test, options) {
26
26
  const codecept = new Codecept(config, options)
27
27
 
28
28
  try {
29
- codecept.init(testRoot)
29
+ await codecept.init(testRoot)
30
30
  await codecept.bootstrap()
31
31
  codecept.loadTests(test)
32
32
 
33
33
  if (options.verbose) {
34
34
  global.debugMode = true
35
- const { getMachineInfo } = require('./info')
35
+ const { getMachineInfo } = await import('./info.js')
36
36
  await getMachineInfo()
37
37
  }
38
38
 
@@ -1,23 +1,25 @@
1
- const fs = require('fs')
2
- const path = require('path')
3
- const util = require('util')
4
- const mkdirp = require('mkdirp')
1
+ import fs from 'fs'
2
+ import path from 'path'
3
+ import util from 'util'
4
+ import { mkdirp } from 'mkdirp'
5
5
 
6
- const output = require('../output')
7
- const { fileExists, beautify } = require('../utils')
6
+ import output from '../output.js'
7
+ import { fileExists, beautify, deepMerge } from '../utils.js'
8
8
 
9
9
  // alias to deep merge
10
- module.exports.deepMerge = require('../utils').deepMerge
10
+ export { deepMerge }
11
11
 
12
- module.exports.getConfig = function (configFile) {
12
+ export async function getConfig(configFile) {
13
13
  try {
14
- return require('../config').load(configFile)
14
+ const configModule = await import('../config.js')
15
+ const config = configModule.default || configModule
16
+ return await config.load(configFile)
15
17
  } catch (err) {
16
18
  fail(err.stack)
17
19
  }
18
20
  }
19
21
 
20
- module.exports.readConfig = function (configFile) {
22
+ export function readConfig(configFile) {
21
23
  try {
22
24
  const data = fs.readFileSync(configFile, 'utf8')
23
25
  return data
@@ -29,18 +31,17 @@ module.exports.readConfig = function (configFile) {
29
31
  function getTestRoot(currentPath) {
30
32
  if (!currentPath) currentPath = '.'
31
33
  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
+ currentPath = fs.lstatSync(currentPath).isDirectory() || !path.extname(currentPath) ? currentPath : path.dirname(currentPath)
34
35
  return currentPath
35
36
  }
36
- module.exports.getTestRoot = getTestRoot
37
+ export { getTestRoot }
37
38
 
38
39
  function fail(msg) {
39
40
  output.error(msg)
40
41
  process.exit(1)
41
42
  }
42
43
 
43
- module.exports.fail = fail
44
+ export { fail }
44
45
 
45
46
  function updateConfig(testsPath, config, extension) {
46
47
  const configFile = path.join(testsPath, `codecept.conf.${extension}`)
@@ -58,7 +59,7 @@ function updateConfig(testsPath, config, extension) {
58
59
  return fs.writeFileSync(configFile, beautify(`exports.config = ${util.inspect(config, false, 4, false)}`), 'utf-8')
59
60
  }
60
61
 
61
- module.exports.updateConfig = updateConfig
62
+ export { updateConfig }
62
63
 
63
64
  function safeFileWrite(file, contents) {
64
65
  if (fileExists(file)) {
@@ -69,9 +70,9 @@ function safeFileWrite(file, contents) {
69
70
  return true
70
71
  }
71
72
 
72
- module.exports.safeFileWrite = safeFileWrite
73
+ export { safeFileWrite }
73
74
 
74
- module.exports.captureStream = (stream) => {
75
+ export const captureStream = stream => {
75
76
  let oldStream
76
77
  let buffer = ''
77
78
 
@@ -79,7 +80,7 @@ module.exports.captureStream = (stream) => {
79
80
  startCapture() {
80
81
  buffer = ''
81
82
  oldStream = stream.write.bind(stream)
82
- stream.write = (chunk) => (buffer += chunk)
83
+ stream.write = chunk => (buffer += chunk)
83
84
  },
84
85
  stopCapture() {
85
86
  if (oldStream !== undefined) stream.write = oldStream
@@ -88,14 +89,14 @@ module.exports.captureStream = (stream) => {
88
89
  }
89
90
  }
90
91
 
91
- module.exports.printError = (err) => {
92
+ export const printError = err => {
92
93
  output.print('')
93
94
  output.error(err.message)
94
95
  output.print('')
95
96
  output.print(output.colors.grey(err.stack.replace(err.message, '')))
96
97
  }
97
98
 
98
- module.exports.createOutputDir = (config, testRoot) => {
99
+ export const createOutputDir = (config, testRoot) => {
99
100
  let outputDir
100
101
  if (path.isAbsolute(config.output)) outputDir = config.output
101
102
  else outputDir = path.join(testRoot, config.output)
@@ -106,7 +107,7 @@ module.exports.createOutputDir = (config, testRoot) => {
106
107
  }
107
108
  }
108
109
 
109
- module.exports.findConfigFile = (testsPath) => {
110
+ export const findConfigFile = testsPath => {
110
111
  const extensions = ['js', 'ts']
111
112
  for (const ext of extensions) {
112
113
  const configFile = path.join(testsPath, `codecept.conf.${ext}`)