codeceptjs 4.0.0-beta.5 → 4.0.0-beta.7.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 (179) hide show
  1. package/README.md +0 -45
  2. package/bin/codecept.js +46 -57
  3. package/lib/actor.js +15 -11
  4. package/lib/ai.js +6 -5
  5. package/lib/assert/empty.js +9 -8
  6. package/lib/assert/equal.js +15 -17
  7. package/lib/assert/error.js +2 -2
  8. package/lib/assert/include.js +9 -11
  9. package/lib/assert/throws.js +1 -1
  10. package/lib/assert/truth.js +8 -5
  11. package/lib/assert.js +18 -18
  12. package/lib/codecept.js +66 -107
  13. package/lib/colorUtils.js +48 -50
  14. package/lib/command/check.js +32 -27
  15. package/lib/command/configMigrate.js +11 -10
  16. package/lib/command/definitions.js +16 -10
  17. package/lib/command/dryRun.js +16 -16
  18. package/lib/command/generate.js +29 -26
  19. package/lib/command/gherkin/init.js +36 -38
  20. package/lib/command/gherkin/snippets.js +14 -14
  21. package/lib/command/gherkin/steps.js +21 -18
  22. package/lib/command/info.js +8 -8
  23. package/lib/command/init.js +34 -31
  24. package/lib/command/interactive.js +11 -10
  25. package/lib/command/list.js +10 -9
  26. package/lib/command/run-multiple/chunk.js +5 -5
  27. package/lib/command/run-multiple/collection.js +5 -5
  28. package/lib/command/run-multiple/run.js +3 -3
  29. package/lib/command/run-multiple.js +16 -13
  30. package/lib/command/run-rerun.js +6 -7
  31. package/lib/command/run-workers.js +10 -24
  32. package/lib/command/run.js +8 -8
  33. package/lib/command/utils.js +20 -18
  34. package/lib/command/workers/runTests.js +117 -269
  35. package/lib/config.js +111 -49
  36. package/lib/container.js +299 -102
  37. package/lib/data/context.js +6 -5
  38. package/lib/data/dataScenarioConfig.js +1 -1
  39. package/lib/data/dataTableArgument.js +1 -1
  40. package/lib/data/table.js +1 -1
  41. package/lib/effects.js +94 -10
  42. package/lib/els.js +11 -9
  43. package/lib/event.js +11 -10
  44. package/lib/globals.js +141 -0
  45. package/lib/heal.js +12 -12
  46. package/lib/helper/AI.js +1 -1
  47. package/lib/helper/ApiDataFactory.js +16 -13
  48. package/lib/helper/FileSystem.js +32 -12
  49. package/lib/helper/GraphQL.js +1 -1
  50. package/lib/helper/GraphQLDataFactory.js +1 -1
  51. package/lib/helper/JSONResponse.js +19 -30
  52. package/lib/helper/Mochawesome.js +9 -28
  53. package/lib/helper/Playwright.js +668 -265
  54. package/lib/helper/Puppeteer.js +284 -169
  55. package/lib/helper/REST.js +29 -12
  56. package/lib/helper/WebDriver.js +192 -71
  57. package/lib/helper/errors/ConnectionRefused.js +6 -6
  58. package/lib/helper/errors/ElementAssertion.js +11 -16
  59. package/lib/helper/errors/ElementNotFound.js +5 -9
  60. package/lib/helper/errors/RemoteBrowserConnectionRefused.js +5 -5
  61. package/lib/helper/extras/Console.js +11 -11
  62. package/lib/helper/extras/PlaywrightLocator.js +110 -0
  63. package/lib/helper/extras/PlaywrightPropEngine.js +18 -18
  64. package/lib/helper/extras/PlaywrightRestartOpts.js +23 -23
  65. package/lib/helper/extras/Popup.js +1 -1
  66. package/lib/helper/extras/React.js +29 -30
  67. package/lib/helper/network/actions.js +33 -48
  68. package/lib/helper/network/utils.js +76 -83
  69. package/lib/helper/scripts/blurElement.js +6 -6
  70. package/lib/helper/scripts/focusElement.js +6 -6
  71. package/lib/helper/scripts/highlightElement.js +9 -9
  72. package/lib/helper/scripts/isElementClickable.js +34 -34
  73. package/lib/helper.js +2 -1
  74. package/lib/history.js +23 -20
  75. package/lib/hooks.js +10 -10
  76. package/lib/html.js +90 -100
  77. package/lib/index.js +48 -21
  78. package/lib/listener/config.js +8 -9
  79. package/lib/listener/emptyRun.js +6 -7
  80. package/lib/listener/exit.js +4 -3
  81. package/lib/listener/globalRetry.js +5 -5
  82. package/lib/listener/globalTimeout.js +11 -10
  83. package/lib/listener/helpers.js +33 -14
  84. package/lib/listener/mocha.js +3 -4
  85. package/lib/listener/result.js +4 -5
  86. package/lib/listener/steps.js +7 -18
  87. package/lib/listener/store.js +3 -3
  88. package/lib/locator.js +213 -192
  89. package/lib/mocha/asyncWrapper.js +108 -75
  90. package/lib/mocha/bdd.js +99 -13
  91. package/lib/mocha/cli.js +60 -27
  92. package/lib/mocha/factory.js +75 -19
  93. package/lib/mocha/featureConfig.js +1 -1
  94. package/lib/mocha/gherkin.js +57 -25
  95. package/lib/mocha/hooks.js +12 -3
  96. package/lib/mocha/index.js +13 -4
  97. package/lib/mocha/inject.js +22 -5
  98. package/lib/mocha/scenarioConfig.js +2 -2
  99. package/lib/mocha/suite.js +9 -2
  100. package/lib/mocha/test.js +10 -13
  101. package/lib/mocha/ui.js +28 -31
  102. package/lib/output.js +11 -9
  103. package/lib/parser.js +44 -44
  104. package/lib/pause.js +15 -16
  105. package/lib/plugin/analyze.js +19 -12
  106. package/lib/plugin/auth.js +20 -21
  107. package/lib/plugin/autoDelay.js +12 -8
  108. package/lib/plugin/coverage.js +12 -8
  109. package/lib/plugin/customLocator.js +3 -3
  110. package/lib/plugin/customReporter.js +3 -2
  111. package/lib/plugin/heal.js +14 -9
  112. package/lib/plugin/pageInfo.js +10 -10
  113. package/lib/plugin/pauseOnFail.js +4 -3
  114. package/lib/plugin/retryFailedStep.js +47 -5
  115. package/lib/plugin/screenshotOnFail.js +75 -37
  116. package/lib/plugin/stepByStepReport.js +14 -14
  117. package/lib/plugin/stepTimeout.js +4 -3
  118. package/lib/plugin/subtitles.js +6 -5
  119. package/lib/recorder.js +33 -23
  120. package/lib/rerun.js +69 -26
  121. package/lib/result.js +4 -4
  122. package/lib/secret.js +18 -17
  123. package/lib/session.js +95 -89
  124. package/lib/step/base.js +6 -6
  125. package/lib/step/config.js +1 -1
  126. package/lib/step/func.js +3 -3
  127. package/lib/step/helper.js +3 -3
  128. package/lib/step/meta.js +4 -4
  129. package/lib/step/record.js +11 -11
  130. package/lib/step/retry.js +3 -3
  131. package/lib/step/section.js +3 -3
  132. package/lib/step.js +7 -10
  133. package/lib/steps.js +9 -5
  134. package/lib/store.js +1 -1
  135. package/lib/timeout.js +1 -7
  136. package/lib/transform.js +8 -8
  137. package/lib/translation.js +32 -18
  138. package/lib/utils.js +68 -97
  139. package/lib/workerStorage.js +16 -17
  140. package/lib/workers.js +145 -171
  141. package/package.json +58 -55
  142. package/translations/de-DE.js +2 -2
  143. package/translations/fr-FR.js +2 -2
  144. package/translations/index.js +23 -10
  145. package/translations/it-IT.js +2 -2
  146. package/translations/ja-JP.js +2 -2
  147. package/translations/nl-NL.js +2 -2
  148. package/translations/pl-PL.js +2 -2
  149. package/translations/pt-BR.js +2 -2
  150. package/translations/ru-RU.js +2 -2
  151. package/translations/utils.js +4 -3
  152. package/translations/zh-CN.js +2 -2
  153. package/translations/zh-TW.js +2 -2
  154. package/typings/index.d.ts +7 -18
  155. package/typings/promiseBasedTypes.d.ts +3769 -5450
  156. package/typings/types.d.ts +3953 -5778
  157. package/bin/test-server.js +0 -53
  158. package/lib/element/WebElement.js +0 -327
  159. package/lib/helper/Nightmare.js +0 -1486
  160. package/lib/helper/Protractor.js +0 -1840
  161. package/lib/helper/TestCafe.js +0 -1391
  162. package/lib/helper/clientscripts/nightmare.js +0 -213
  163. package/lib/helper/extras/PlaywrightReactVueLocator.js +0 -43
  164. package/lib/helper/testcafe/testControllerHolder.js +0 -42
  165. package/lib/helper/testcafe/testcafe-utils.js +0 -61
  166. package/lib/listener/retryEnhancer.js +0 -85
  167. package/lib/plugin/allure.js +0 -15
  168. package/lib/plugin/autoLogin.js +0 -5
  169. package/lib/plugin/commentStep.js +0 -141
  170. package/lib/plugin/eachElement.js +0 -127
  171. package/lib/plugin/fakerTransform.js +0 -49
  172. package/lib/plugin/htmlReporter.js +0 -1947
  173. package/lib/plugin/retryTo.js +0 -16
  174. package/lib/plugin/selenoid.js +0 -364
  175. package/lib/plugin/standardActingHelpers.js +0 -6
  176. package/lib/plugin/tryTo.js +0 -16
  177. package/lib/plugin/wdio.js +0 -247
  178. package/lib/test-server.js +0 -323
  179. package/lib/within.js +0 -90
@@ -1,13 +1,16 @@
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 = {}
@@ -24,7 +27,7 @@ let subprocessCount = 0
24
27
  let totalSubprocessCount = 0
25
28
  let processesDone
26
29
 
27
- module.exports = async function (selectedRuns, options) {
30
+ export default async function (selectedRuns, options) {
28
31
  // registering options globally to use in config
29
32
  if (options.profile) {
30
33
  process.env.profile = options.profile
@@ -49,7 +52,7 @@ module.exports = async function (selectedRuns, options) {
49
52
  }
50
53
 
51
54
  config = {
52
- ...getConfig(configFile),
55
+ ...(await getConfig(configFile)),
53
56
  ...overrides,
54
57
  }
55
58
 
@@ -88,7 +91,7 @@ module.exports = async function (selectedRuns, options) {
88
91
  })
89
92
 
90
93
  const runsToExecute = []
91
- collection.createRuns(selectedRuns, config).forEach(run => {
94
+ createRuns(selectedRuns, config).forEach(run => {
92
95
  const runName = run.getOriginalName() || run.getName()
93
96
  const runConfig = run.getConfig()
94
97
  runsToExecute.push(executeRun(runName, runConfig))
@@ -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,31 +1,18 @@
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')
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'
7
9
 
8
- module.exports = async function (workerCount, selectedRuns, options) {
10
+ export default async function (workerCount, selectedRuns, options) {
9
11
  process.env.profile = options.profile
10
12
 
11
13
  const { config: testConfig, override = '' } = options
12
14
  const overrideConfigs = tryOrDefault(() => JSON.parse(override), {})
13
-
14
- // Determine test split strategy
15
- let by = 'test' // default
16
- if (options.by) {
17
- // Explicit --by option takes precedence
18
- by = options.by
19
- } else if (options.suites) {
20
- // Legacy --suites option
21
- by = 'suite'
22
- }
23
-
24
- // Validate the by option
25
- const validStrategies = ['test', 'suite', 'pool']
26
- if (!validStrategies.includes(by)) {
27
- throw new Error(`Invalid --by strategy: ${by}. Valid options are: ${validStrategies.join(', ')}`)
28
- }
15
+ const by = options.suites ? 'suite' : 'test'
29
16
  delete options.parent
30
17
  const config = {
31
18
  by,
@@ -36,7 +23,7 @@ module.exports = async function (workerCount, selectedRuns, options) {
36
23
 
37
24
  const numberOfWorkers = parseInt(workerCount, 10)
38
25
 
39
- output.print(`CodeceptJS v${require('../codecept').version()} ${output.standWithUkraine()}`)
26
+ output.print(`CodeceptJS v${Codecept.version()} ${output.standWithUkraine()}`)
40
27
  output.print(`Running tests in ${output.styles.bold(numberOfWorkers)} workers...`)
41
28
  output.print()
42
29
  store.hasWorkers = true
@@ -64,7 +51,6 @@ module.exports = async function (workerCount, selectedRuns, options) {
64
51
  if (options.verbose || options.debug) store.debugMode = true
65
52
 
66
53
  if (options.verbose) {
67
- const { getMachineInfo } = require('./info')
68
54
  await getMachineInfo()
69
55
  }
70
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
@@ -32,14 +34,14 @@ function getTestRoot(currentPath) {
32
34
  currentPath = fs.lstatSync(currentPath).isDirectory() || !path.extname(currentPath) ? currentPath : path.dirname(currentPath)
33
35
  return currentPath
34
36
  }
35
- module.exports.getTestRoot = getTestRoot
37
+ export { getTestRoot }
36
38
 
37
39
  function fail(msg) {
38
40
  output.error(msg)
39
41
  process.exit(1)
40
42
  }
41
43
 
42
- module.exports.fail = fail
44
+ export { fail }
43
45
 
44
46
  function updateConfig(testsPath, config, extension) {
45
47
  const configFile = path.join(testsPath, `codecept.conf.${extension}`)
@@ -57,7 +59,7 @@ function updateConfig(testsPath, config, extension) {
57
59
  return fs.writeFileSync(configFile, beautify(`exports.config = ${util.inspect(config, false, 4, false)}`), 'utf-8')
58
60
  }
59
61
 
60
- module.exports.updateConfig = updateConfig
62
+ export { updateConfig }
61
63
 
62
64
  function safeFileWrite(file, contents) {
63
65
  if (fileExists(file)) {
@@ -68,9 +70,9 @@ function safeFileWrite(file, contents) {
68
70
  return true
69
71
  }
70
72
 
71
- module.exports.safeFileWrite = safeFileWrite
73
+ export { safeFileWrite }
72
74
 
73
- module.exports.captureStream = stream => {
75
+ export const captureStream = stream => {
74
76
  let oldStream
75
77
  let buffer = ''
76
78
 
@@ -87,14 +89,14 @@ module.exports.captureStream = stream => {
87
89
  }
88
90
  }
89
91
 
90
- module.exports.printError = err => {
92
+ export const printError = err => {
91
93
  output.print('')
92
94
  output.error(err.message)
93
95
  output.print('')
94
96
  output.print(output.colors.grey(err.stack.replace(err.message, '')))
95
97
  }
96
98
 
97
- module.exports.createOutputDir = (config, testRoot) => {
99
+ export const createOutputDir = (config, testRoot) => {
98
100
  let outputDir
99
101
  if (path.isAbsolute(config.output)) outputDir = config.output
100
102
  else outputDir = path.join(testRoot, config.output)
@@ -105,7 +107,7 @@ module.exports.createOutputDir = (config, testRoot) => {
105
107
  }
106
108
  }
107
109
 
108
- module.exports.findConfigFile = testsPath => {
110
+ export const findConfigFile = testsPath => {
109
111
  const extensions = ['js', 'ts']
110
112
  for (const ext of extensions) {
111
113
  const configFile = path.join(testsPath, `codecept.conf.${ext}`)