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.
- package/README.md +89 -119
- package/bin/codecept.js +53 -54
- package/docs/webapi/clearCookie.mustache +1 -1
- package/lib/actor.js +70 -102
- package/lib/ai.js +131 -121
- package/lib/assert/empty.js +11 -12
- package/lib/assert/equal.js +16 -21
- package/lib/assert/error.js +2 -2
- package/lib/assert/include.js +11 -15
- package/lib/assert/throws.js +3 -5
- package/lib/assert/truth.js +10 -7
- package/lib/assert.js +18 -18
- package/lib/codecept.js +112 -101
- package/lib/colorUtils.js +48 -50
- package/lib/command/check.js +206 -0
- package/lib/command/configMigrate.js +13 -14
- package/lib/command/definitions.js +24 -36
- package/lib/command/dryRun.js +16 -16
- package/lib/command/generate.js +38 -39
- package/lib/command/gherkin/init.js +36 -38
- package/lib/command/gherkin/snippets.js +76 -74
- package/lib/command/gherkin/steps.js +21 -18
- package/lib/command/info.js +49 -15
- package/lib/command/init.js +41 -37
- package/lib/command/interactive.js +22 -13
- package/lib/command/list.js +11 -10
- package/lib/command/run-multiple/chunk.js +50 -47
- package/lib/command/run-multiple/collection.js +5 -5
- package/lib/command/run-multiple/run.js +3 -3
- package/lib/command/run-multiple.js +27 -47
- package/lib/command/run-rerun.js +6 -7
- package/lib/command/run-workers.js +15 -66
- package/lib/command/run.js +8 -8
- package/lib/command/utils.js +22 -21
- package/lib/command/workers/runTests.js +131 -241
- package/lib/config.js +111 -49
- package/lib/container.js +589 -244
- package/lib/data/context.js +16 -18
- package/lib/data/dataScenarioConfig.js +9 -9
- package/lib/data/dataTableArgument.js +7 -7
- package/lib/data/table.js +6 -12
- package/lib/effects.js +307 -0
- package/lib/els.js +160 -0
- package/lib/event.js +24 -19
- package/lib/globals.js +141 -0
- package/lib/heal.js +89 -81
- package/lib/helper/AI.js +3 -2
- package/lib/helper/ApiDataFactory.js +19 -19
- package/lib/helper/Appium.js +47 -51
- package/lib/helper/FileSystem.js +35 -15
- package/lib/helper/GraphQL.js +1 -1
- package/lib/helper/GraphQLDataFactory.js +4 -4
- package/lib/helper/JSONResponse.js +72 -45
- package/lib/helper/Mochawesome.js +14 -11
- package/lib/helper/Playwright.js +832 -434
- package/lib/helper/Puppeteer.js +393 -292
- package/lib/helper/REST.js +32 -27
- package/lib/helper/WebDriver.js +320 -219
- package/lib/helper/errors/ConnectionRefused.js +6 -6
- package/lib/helper/errors/ElementAssertion.js +11 -16
- package/lib/helper/errors/ElementNotFound.js +5 -9
- package/lib/helper/errors/RemoteBrowserConnectionRefused.js +5 -5
- package/lib/helper/extras/Console.js +11 -11
- package/lib/helper/extras/PlaywrightLocator.js +110 -0
- package/lib/helper/extras/PlaywrightPropEngine.js +18 -18
- package/lib/helper/extras/PlaywrightRestartOpts.js +23 -23
- package/lib/helper/extras/Popup.js +22 -22
- package/lib/helper/extras/React.js +29 -30
- package/lib/helper/network/actions.js +33 -48
- package/lib/helper/network/utils.js +76 -83
- package/lib/helper/scripts/blurElement.js +6 -6
- package/lib/helper/scripts/focusElement.js +6 -6
- package/lib/helper/scripts/highlightElement.js +9 -9
- package/lib/helper/scripts/isElementClickable.js +34 -34
- package/lib/helper.js +2 -1
- package/lib/history.js +23 -20
- package/lib/hooks.js +10 -10
- package/lib/html.js +90 -100
- package/lib/index.js +48 -21
- package/lib/listener/config.js +8 -9
- package/lib/listener/emptyRun.js +54 -0
- package/lib/listener/exit.js +10 -12
- package/lib/listener/{retry.js → globalRetry.js} +10 -10
- package/lib/listener/globalTimeout.js +166 -0
- package/lib/listener/helpers.js +43 -24
- package/lib/listener/mocha.js +4 -5
- package/lib/listener/result.js +11 -0
- package/lib/listener/steps.js +26 -23
- package/lib/listener/store.js +20 -0
- package/lib/locator.js +213 -192
- package/lib/mocha/asyncWrapper.js +264 -0
- package/lib/mocha/bdd.js +167 -0
- package/lib/mocha/cli.js +341 -0
- package/lib/mocha/factory.js +160 -0
- package/lib/{interfaces → mocha}/featureConfig.js +33 -13
- package/lib/{interfaces → mocha}/gherkin.js +75 -45
- package/lib/mocha/hooks.js +121 -0
- package/lib/mocha/index.js +21 -0
- package/lib/mocha/inject.js +46 -0
- package/lib/{interfaces → mocha}/scenarioConfig.js +32 -8
- package/lib/mocha/suite.js +89 -0
- package/lib/mocha/test.js +178 -0
- package/lib/mocha/types.d.ts +42 -0
- package/lib/mocha/ui.js +229 -0
- package/lib/output.js +86 -64
- package/lib/parser.js +44 -44
- package/lib/pause.js +160 -139
- package/lib/plugin/analyze.js +403 -0
- package/lib/plugin/{autoLogin.js → auth.js} +137 -43
- package/lib/plugin/autoDelay.js +19 -15
- package/lib/plugin/coverage.js +22 -27
- package/lib/plugin/customLocator.js +5 -5
- package/lib/plugin/customReporter.js +53 -0
- package/lib/plugin/heal.js +49 -17
- package/lib/plugin/pageInfo.js +140 -0
- package/lib/plugin/pauseOnFail.js +4 -3
- package/lib/plugin/retryFailedStep.js +60 -19
- package/lib/plugin/screenshotOnFail.js +80 -83
- package/lib/plugin/stepByStepReport.js +70 -31
- package/lib/plugin/stepTimeout.js +7 -13
- package/lib/plugin/subtitles.js +10 -9
- package/lib/recorder.js +167 -126
- package/lib/rerun.js +94 -50
- package/lib/result.js +161 -0
- package/lib/secret.js +18 -17
- package/lib/session.js +95 -89
- package/lib/step/base.js +239 -0
- package/lib/step/comment.js +10 -0
- package/lib/step/config.js +50 -0
- package/lib/step/func.js +46 -0
- package/lib/step/helper.js +50 -0
- package/lib/step/meta.js +99 -0
- package/lib/step/record.js +74 -0
- package/lib/step/retry.js +11 -0
- package/lib/step/section.js +55 -0
- package/lib/step.js +18 -332
- package/lib/steps.js +54 -0
- package/lib/store.js +37 -5
- package/lib/template/heal.js +2 -11
- package/lib/timeout.js +60 -0
- package/lib/transform.js +8 -8
- package/lib/translation.js +32 -18
- package/lib/utils.js +354 -250
- package/lib/workerStorage.js +16 -16
- package/lib/workers.js +366 -282
- package/package.json +107 -95
- package/translations/de-DE.js +5 -4
- package/translations/fr-FR.js +5 -4
- package/translations/index.js +23 -9
- package/translations/it-IT.js +5 -4
- package/translations/ja-JP.js +5 -4
- package/translations/nl-NL.js +76 -0
- package/translations/pl-PL.js +5 -4
- package/translations/pt-BR.js +5 -4
- package/translations/ru-RU.js +5 -4
- package/translations/utils.js +18 -0
- package/translations/zh-CN.js +5 -4
- package/translations/zh-TW.js +5 -4
- package/typings/index.d.ts +177 -186
- package/typings/promiseBasedTypes.d.ts +3573 -5941
- package/typings/types.d.ts +4042 -6370
- package/lib/cli.js +0 -256
- package/lib/helper/ExpectHelper.js +0 -391
- package/lib/helper/Nightmare.js +0 -1504
- package/lib/helper/Protractor.js +0 -1863
- package/lib/helper/SoftExpectHelper.js +0 -381
- package/lib/helper/TestCafe.js +0 -1414
- package/lib/helper/clientscripts/nightmare.js +0 -213
- package/lib/helper/extras/PlaywrightReactVueLocator.js +0 -43
- package/lib/helper/testcafe/testControllerHolder.js +0 -42
- package/lib/helper/testcafe/testcafe-utils.js +0 -62
- package/lib/interfaces/bdd.js +0 -81
- package/lib/listener/artifacts.js +0 -19
- package/lib/listener/timeout.js +0 -109
- package/lib/mochaFactory.js +0 -113
- package/lib/plugin/allure.js +0 -15
- package/lib/plugin/commentStep.js +0 -136
- package/lib/plugin/debugErrors.js +0 -67
- package/lib/plugin/eachElement.js +0 -127
- package/lib/plugin/fakerTransform.js +0 -49
- package/lib/plugin/retryTo.js +0 -127
- package/lib/plugin/selenoid.js +0 -384
- package/lib/plugin/standardActingHelpers.js +0 -3
- package/lib/plugin/tryTo.js +0 -115
- package/lib/plugin/wdio.js +0 -249
- package/lib/scenario.js +0 -224
- package/lib/ui.js +0 -236
- package/lib/within.js +0 -70
package/lib/command/info.js
CHANGED
|
@@ -1,25 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
import envinfo from 'envinfo'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { getConfig, getTestRoot } from './utils.js'
|
|
4
|
+
import Codecept from '../codecept.js'
|
|
5
|
+
import output from '../output.js'
|
|
6
|
+
import { execSync } from 'child_process'
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
async function getPlaywrightBrowsers() {
|
|
9
|
+
try {
|
|
10
|
+
const regex = /(chromium|firefox|webkit)\s+version\s+([\d.]+)/gi
|
|
11
|
+
let versions = []
|
|
12
|
+
|
|
13
|
+
const info = execSync('npx playwright install --dry-run').toString().trim()
|
|
14
|
+
|
|
15
|
+
const matches = [...info.matchAll(regex)]
|
|
16
|
+
|
|
17
|
+
matches.forEach(match => {
|
|
18
|
+
const browser = match[1]
|
|
19
|
+
const version = match[2]
|
|
20
|
+
versions.push(`${browser}: ${version}`)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
return versions.join(', ')
|
|
24
|
+
} catch (err) {
|
|
25
|
+
return 'Playwright not installed'
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function getOsBrowsers() {
|
|
30
|
+
const chromeInfo = await envinfo.helpers.getChromeInfo()
|
|
31
|
+
const edgeInfo = await envinfo.helpers.getEdgeInfo()
|
|
32
|
+
const firefoxInfo = await envinfo.helpers.getFirefoxInfo()
|
|
33
|
+
const safariInfo = await envinfo.helpers.getSafariInfo()
|
|
34
|
+
|
|
35
|
+
return [
|
|
36
|
+
`chrome: ${chromeInfo ? chromeInfo[1] : 'not installed'}`,
|
|
37
|
+
`edge: ${edgeInfo ? edgeInfo[1] : 'not installed'}`,
|
|
38
|
+
`firefox: ${firefoxInfo ? firefoxInfo[1] : 'not installed'}`,
|
|
39
|
+
`safari: ${safariInfo ? safariInfo[1] : 'not installed'}`,
|
|
40
|
+
].join(', ')
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default async function (path) {
|
|
8
44
|
const testsPath = getTestRoot(path)
|
|
9
|
-
const config = getConfig(testsPath)
|
|
45
|
+
const config = await getConfig(testsPath)
|
|
10
46
|
const codecept = new Codecept(config, {})
|
|
11
47
|
codecept.init(testsPath)
|
|
12
48
|
|
|
13
|
-
output.print('\n Environment information
|
|
49
|
+
output.print('\n Environment information: \n')
|
|
14
50
|
const info = {}
|
|
15
51
|
info.codeceptVersion = Codecept.version()
|
|
16
52
|
info.nodeInfo = await envinfo.helpers.getNodeInfo()
|
|
17
53
|
info.osInfo = await envinfo.helpers.getOSInfo()
|
|
18
54
|
info.cpuInfo = await envinfo.helpers.getCPUInfo()
|
|
19
|
-
info.
|
|
20
|
-
info.
|
|
21
|
-
|
|
22
|
-
info.safariInfo = await envinfo.helpers.getSafariInfo()
|
|
55
|
+
info.osBrowsers = await getOsBrowsers()
|
|
56
|
+
info.playwrightBrowsers = await getPlaywrightBrowsers()
|
|
57
|
+
|
|
23
58
|
const { helpers, plugins } = config
|
|
24
59
|
info.helpers = helpers || "You don't use any helpers"
|
|
25
60
|
info.plugins = plugins || "You don't have any enabled plugins"
|
|
@@ -34,13 +69,11 @@ module.exports = async function (path) {
|
|
|
34
69
|
output.print('***************************************')
|
|
35
70
|
output.print('If you have questions ask them in our Slack: http://bit.ly/chat-codeceptjs')
|
|
36
71
|
output.print('Or ask them on our discussion board: https://codecept.discourse.group/')
|
|
37
|
-
output.print(
|
|
38
|
-
'Please copy environment info when you report issues on GitHub: https://github.com/Codeception/CodeceptJS/issues',
|
|
39
|
-
)
|
|
72
|
+
output.print('Please copy environment info when you report issues on GitHub: https://github.com/Codeception/CodeceptJS/issues')
|
|
40
73
|
output.print('***************************************')
|
|
41
74
|
}
|
|
42
75
|
|
|
43
|
-
|
|
76
|
+
export const getMachineInfo = async () => {
|
|
44
77
|
const info = {
|
|
45
78
|
nodeInfo: await envinfo.helpers.getNodeInfo(),
|
|
46
79
|
osInfo: await envinfo.helpers.getOSInfo(),
|
|
@@ -49,6 +82,7 @@ module.exports.getMachineInfo = async () => {
|
|
|
49
82
|
edgeInfo: await envinfo.helpers.getEdgeInfo(),
|
|
50
83
|
firefoxInfo: await envinfo.helpers.getFirefoxInfo(),
|
|
51
84
|
safariInfo: await envinfo.helpers.getSafariInfo(),
|
|
85
|
+
playwrightBrowsers: await getPlaywrightBrowsers(),
|
|
52
86
|
}
|
|
53
87
|
|
|
54
88
|
output.print('***************************************')
|
package/lib/command/init.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import colors from 'chalk'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import inquirer from 'inquirer'
|
|
4
|
+
import { mkdirp } from 'mkdirp'
|
|
5
|
+
import path from 'path'
|
|
6
|
+
import { inspect } from 'util'
|
|
7
|
+
import spawn from 'cross-spawn'
|
|
8
|
+
|
|
9
|
+
import output from '../output.js'
|
|
10
|
+
const { print, success, error } = output
|
|
11
|
+
import { fileExists, beautify, installedLocally } from '../utils.js'
|
|
12
|
+
import { getTestRoot } from './utils.js'
|
|
13
|
+
import generateDefinitions from './definitions.js'
|
|
14
|
+
import { test as generateTest } from './generate.js'
|
|
15
|
+
const isLocal = installedLocally()
|
|
15
16
|
|
|
16
17
|
const defaultConfig = {
|
|
17
18
|
tests: './*_test.js',
|
|
@@ -20,11 +21,15 @@ const defaultConfig = {
|
|
|
20
21
|
include: {},
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
const helpers = ['Playwright', 'WebDriver', 'Puppeteer', 'REST', 'GraphQL', 'Appium'
|
|
24
|
-
const translations = Object.keys(require('../../translations'))
|
|
25
|
-
|
|
24
|
+
const helpers = ['Playwright', 'WebDriver', 'Puppeteer', 'REST', 'GraphQL', 'Appium']
|
|
26
25
|
const noTranslation = 'English (no localization)'
|
|
27
|
-
|
|
26
|
+
|
|
27
|
+
async function getTranslations() {
|
|
28
|
+
const translationsModule = await import('../../translations/index.js')
|
|
29
|
+
const translations = Object.keys(translationsModule.default || translationsModule)
|
|
30
|
+
translations.unshift(noTranslation)
|
|
31
|
+
return translations
|
|
32
|
+
}
|
|
28
33
|
|
|
29
34
|
const packages = []
|
|
30
35
|
let isTypeScript = false
|
|
@@ -45,7 +50,7 @@ setCommonPlugins();
|
|
|
45
50
|
|
|
46
51
|
const defaultActor = `// in this file you can append custom step methods to 'I' object
|
|
47
52
|
|
|
48
|
-
|
|
53
|
+
export default function() {
|
|
49
54
|
return actor({
|
|
50
55
|
|
|
51
56
|
// Define custom steps here, use 'this' to access default methods of I.
|
|
@@ -67,8 +72,9 @@ export = function() {
|
|
|
67
72
|
}
|
|
68
73
|
`
|
|
69
74
|
|
|
70
|
-
|
|
75
|
+
export default async function (initPath) {
|
|
71
76
|
const testsPath = getTestRoot(initPath)
|
|
77
|
+
const translations = await getTranslations()
|
|
72
78
|
|
|
73
79
|
print()
|
|
74
80
|
print(` Welcome to ${colors.magenta.bold('CodeceptJS')} initialization tool`)
|
|
@@ -117,7 +123,7 @@ module.exports = function (initPath) {
|
|
|
117
123
|
{
|
|
118
124
|
name: 'tests',
|
|
119
125
|
type: 'input',
|
|
120
|
-
default:
|
|
126
|
+
default: answers => `./*_test.${answers.typescript ? 'ts' : 'js'}`,
|
|
121
127
|
message: 'Where are your tests located?',
|
|
122
128
|
},
|
|
123
129
|
{
|
|
@@ -132,7 +138,7 @@ module.exports = function (initPath) {
|
|
|
132
138
|
type: 'confirm',
|
|
133
139
|
default: true,
|
|
134
140
|
message: 'Do you want to use JSONResponse helper for assertions on JSON responses? http://bit.ly/3ASVPy9',
|
|
135
|
-
when:
|
|
141
|
+
when: answers => ['GraphQL', 'REST'].includes(answers.helper) === true,
|
|
136
142
|
},
|
|
137
143
|
{
|
|
138
144
|
name: 'output',
|
|
@@ -146,7 +152,7 @@ module.exports = function (initPath) {
|
|
|
146
152
|
choices: translations,
|
|
147
153
|
},
|
|
148
154
|
])
|
|
149
|
-
.then(
|
|
155
|
+
.then(async result => {
|
|
150
156
|
if (result.typescript === true) {
|
|
151
157
|
isTypeScript = true
|
|
152
158
|
extension = isTypeScript === true ? 'ts' : 'js'
|
|
@@ -182,14 +188,15 @@ module.exports = function (initPath) {
|
|
|
182
188
|
let helperConfigs = []
|
|
183
189
|
|
|
184
190
|
try {
|
|
185
|
-
const
|
|
191
|
+
const HelperModule = await import(`../helper/${helperName}.js`)
|
|
192
|
+
const Helper = HelperModule.default || HelperModule
|
|
186
193
|
if (Helper._checkRequirements) {
|
|
187
194
|
packages.concat(Helper._checkRequirements())
|
|
188
195
|
}
|
|
189
196
|
|
|
190
197
|
if (!Helper._config()) return
|
|
191
198
|
helperConfigs = helperConfigs.concat(
|
|
192
|
-
Helper._config().map(
|
|
199
|
+
Helper._config().map(config => {
|
|
193
200
|
config.message = `[${helperName}] ${config.message}`
|
|
194
201
|
config.name = `${helperName}_${config.name}`
|
|
195
202
|
config.type = config.type || 'input'
|
|
@@ -207,9 +214,9 @@ module.exports = function (initPath) {
|
|
|
207
214
|
fs.writeFileSync(path.join(testsPath, stepFile), extension === 'ts' ? defaultActorTs : defaultActor)
|
|
208
215
|
|
|
209
216
|
if (isTypeScript) {
|
|
210
|
-
config.include = _actorTranslation('./steps_file', config.translation)
|
|
217
|
+
config.include = await _actorTranslation('./steps_file', config.translation, translations)
|
|
211
218
|
} else {
|
|
212
|
-
config.include = _actorTranslation(stepFile, config.translation)
|
|
219
|
+
config.include = await _actorTranslation(stepFile, config.translation, translations)
|
|
213
220
|
}
|
|
214
221
|
|
|
215
222
|
print(`Steps file created at ${stepFile}`)
|
|
@@ -225,9 +232,7 @@ module.exports = function (initPath) {
|
|
|
225
232
|
fs.writeFileSync(typeScriptconfigFile, configSource, 'utf-8')
|
|
226
233
|
print(`Config created at ${typeScriptconfigFile}`)
|
|
227
234
|
} else {
|
|
228
|
-
configSource = beautify(
|
|
229
|
-
`/** @type {CodeceptJS.MainConfig} */\nexports.config = ${inspect(config, false, 4, false)}`,
|
|
230
|
-
)
|
|
235
|
+
configSource = beautify(`/** @type {CodeceptJS.MainConfig} */\nexports.config = ${inspect(config, false, 4, false)}`)
|
|
231
236
|
|
|
232
237
|
if (hasConfigure) configSource = requireCodeceptConfigure + configHeader + configSource
|
|
233
238
|
|
|
@@ -286,9 +291,7 @@ module.exports = function (initPath) {
|
|
|
286
291
|
}
|
|
287
292
|
}
|
|
288
293
|
|
|
289
|
-
const generateDefinitionsManually = colors.bold(
|
|
290
|
-
`To get auto-completion support, please generate type definitions: ${colors.green('npx codeceptjs def')}`,
|
|
291
|
-
)
|
|
294
|
+
const generateDefinitionsManually = colors.bold(`To get auto-completion support, please generate type definitions: ${colors.green('npx codeceptjs def')}`)
|
|
292
295
|
|
|
293
296
|
if (packages) {
|
|
294
297
|
try {
|
|
@@ -330,7 +333,7 @@ module.exports = function (initPath) {
|
|
|
330
333
|
}
|
|
331
334
|
|
|
332
335
|
print('Configure helpers...')
|
|
333
|
-
inquirer.prompt(helperConfigs).then(async
|
|
336
|
+
inquirer.prompt(helperConfigs).then(async helperResult => {
|
|
334
337
|
if (helperResult.Playwright_browser === 'electron') {
|
|
335
338
|
delete helperResult.Playwright_url
|
|
336
339
|
delete helperResult.Playwright_show
|
|
@@ -341,7 +344,7 @@ module.exports = function (initPath) {
|
|
|
341
344
|
}
|
|
342
345
|
}
|
|
343
346
|
|
|
344
|
-
Object.keys(helperResult).forEach(
|
|
347
|
+
Object.keys(helperResult).forEach(key => {
|
|
345
348
|
const parts = key.split('_')
|
|
346
349
|
const helperName = parts[0]
|
|
347
350
|
const configName = parts[1]
|
|
@@ -394,7 +397,7 @@ function install(dependencies) {
|
|
|
394
397
|
return true
|
|
395
398
|
}
|
|
396
399
|
|
|
397
|
-
function _actorTranslation(stepFile, translationSelected) {
|
|
400
|
+
async function _actorTranslation(stepFile, translationSelected, translations) {
|
|
398
401
|
let actor
|
|
399
402
|
|
|
400
403
|
for (const translationAvailable of translations) {
|
|
@@ -403,7 +406,8 @@ function _actorTranslation(stepFile, translationSelected) {
|
|
|
403
406
|
}
|
|
404
407
|
|
|
405
408
|
if (translationSelected === translationAvailable) {
|
|
406
|
-
const
|
|
409
|
+
const translationsModule = await import('../../translations/index.js')
|
|
410
|
+
const nameOfActor = (translationsModule.default || translationsModule)[translationAvailable].I
|
|
407
411
|
|
|
408
412
|
actor = {
|
|
409
413
|
[nameOfActor]: stepFile,
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { getConfig, getTestRoot } from './utils.js'
|
|
2
|
+
import recorder from '../recorder.js'
|
|
3
|
+
import Codecept from '../codecept.js'
|
|
4
|
+
import Container from '../container.js'
|
|
5
|
+
import event from '../event.js'
|
|
6
|
+
import pause from '../pause.js'
|
|
7
|
+
import output from '../output.js'
|
|
8
|
+
const webHelpers = Container.STANDARD_ACTING_HELPERS
|
|
9
|
+
|
|
10
|
+
export default async function (path, options) {
|
|
10
11
|
// Backward compatibility for --profile
|
|
11
12
|
process.profile = options.profile
|
|
12
13
|
process.env.profile = options.profile
|
|
13
14
|
const configFile = options.config
|
|
14
15
|
|
|
15
|
-
const config = getConfig(configFile)
|
|
16
|
+
const config = await getConfig(configFile)
|
|
16
17
|
const testsPath = getTestRoot(configFile)
|
|
17
18
|
|
|
18
19
|
const codecept = new Codecept(config, options)
|
|
@@ -20,18 +21,27 @@ module.exports = async function (path, options) {
|
|
|
20
21
|
|
|
21
22
|
try {
|
|
22
23
|
await codecept.bootstrap()
|
|
24
|
+
await Container.started()
|
|
23
25
|
|
|
24
26
|
if (options.verbose) output.level(3)
|
|
25
27
|
|
|
28
|
+
let addGlobalRetries
|
|
29
|
+
|
|
30
|
+
if (config.retry) {
|
|
31
|
+
addGlobalRetries = function retries() {}
|
|
32
|
+
}
|
|
33
|
+
|
|
26
34
|
output.print('Starting interactive shell for current suite...')
|
|
27
35
|
recorder.start()
|
|
28
36
|
event.emit(event.suite.before, {
|
|
29
37
|
fullTitle: () => 'Interactive Shell',
|
|
30
38
|
tests: [],
|
|
39
|
+
retries: addGlobalRetries,
|
|
31
40
|
})
|
|
32
41
|
event.emit(event.test.before, {
|
|
33
42
|
title: '',
|
|
34
43
|
artifacts: {},
|
|
44
|
+
retries: addGlobalRetries,
|
|
35
45
|
})
|
|
36
46
|
|
|
37
47
|
const enabledHelpers = Container.helpers()
|
|
@@ -39,12 +49,11 @@ module.exports = async function (path, options) {
|
|
|
39
49
|
if (webHelpers.includes(helperName)) {
|
|
40
50
|
const I = enabledHelpers[helperName]
|
|
41
51
|
recorder.add(() => I.amOnPage('/'))
|
|
42
|
-
recorder.catchWithoutStop(
|
|
52
|
+
recorder.catchWithoutStop(e => output.print(`Error while loading home page: ${e.message}}`))
|
|
43
53
|
break
|
|
44
54
|
}
|
|
45
55
|
}
|
|
46
|
-
|
|
47
|
-
// recorder.catchWithoutStop((err) => console.log(err.stack));
|
|
56
|
+
pause()
|
|
48
57
|
recorder.add(() => event.emit(event.test.after, {}))
|
|
49
58
|
recorder.add(() => event.emit(event.suite.after, {}))
|
|
50
59
|
recorder.add(() => event.emit(event.all.result, {}))
|
package/lib/command/list.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { getConfig, getTestRoot } from './utils.js'
|
|
2
|
+
import Codecept from '../codecept.js'
|
|
3
|
+
import container from '../container.js'
|
|
4
|
+
import { getParamsToString } from '../parser.js'
|
|
5
|
+
import { methodsOfObject } from '../utils.js'
|
|
6
|
+
import output from '../output.js'
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
export default async function (path) {
|
|
9
9
|
const testsPath = getTestRoot(path)
|
|
10
|
-
const config = getConfig(testsPath)
|
|
10
|
+
const config = await getConfig(testsPath)
|
|
11
11
|
const codecept = new Codecept(config, {})
|
|
12
|
-
codecept.init(testsPath)
|
|
12
|
+
await codecept.init(testsPath)
|
|
13
|
+
await container.started()
|
|
13
14
|
|
|
14
15
|
output.print('List of test actions: -- ')
|
|
15
16
|
const helpers = container.helpers()
|
|
@@ -17,7 +18,7 @@ module.exports = function (path) {
|
|
|
17
18
|
const actions = []
|
|
18
19
|
for (const name in helpers) {
|
|
19
20
|
const helper = helpers[name]
|
|
20
|
-
methodsOfObject(helper).forEach(
|
|
21
|
+
methodsOfObject(helper).forEach(action => {
|
|
21
22
|
const params = getParamsToString(helper[action])
|
|
22
23
|
actions[action] = 1
|
|
23
24
|
output.print(` ${output.colors.grey(name)} I.${output.colors.bold(action)}(${params})`)
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { globSync } from 'glob'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import fs from 'fs'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Splits a list to (n) parts, defined via the size argument.
|
|
7
7
|
*/
|
|
8
8
|
const splitFiles = (list, size) => {
|
|
9
|
-
const sets = []
|
|
10
|
-
const chunks = list.length / size
|
|
11
|
-
let i = 0
|
|
9
|
+
const sets = []
|
|
10
|
+
const chunks = list.length / size
|
|
11
|
+
let i = 0
|
|
12
12
|
|
|
13
13
|
while (i < chunks) {
|
|
14
|
-
sets[i] = list.splice(0, size)
|
|
15
|
-
i
|
|
14
|
+
sets[i] = list.splice(0, size)
|
|
15
|
+
i++
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
return sets
|
|
19
|
-
}
|
|
18
|
+
return sets
|
|
19
|
+
}
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Executes a glob pattern and pushes the results to a list.
|
|
23
23
|
*/
|
|
24
|
-
const findFiles =
|
|
25
|
-
const files = []
|
|
24
|
+
const findFiles = pattern => {
|
|
25
|
+
const files = []
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
files.push(path.resolve(file))
|
|
29
|
-
})
|
|
27
|
+
globSync(pattern).forEach(file => {
|
|
28
|
+
files.push(path.resolve(file))
|
|
29
|
+
})
|
|
30
30
|
|
|
31
|
-
return files
|
|
32
|
-
}
|
|
31
|
+
return files
|
|
32
|
+
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Joins a list of files to a valid glob pattern
|
|
36
36
|
*/
|
|
37
|
-
const flattenFiles =
|
|
38
|
-
const pattern = list.join(',')
|
|
39
|
-
return pattern.indexOf(',') > -1 ? `{${pattern}}` : pattern
|
|
40
|
-
}
|
|
37
|
+
const flattenFiles = list => {
|
|
38
|
+
const pattern = list.join(',')
|
|
39
|
+
return pattern.indexOf(',') > -1 ? `{${pattern}}` : pattern
|
|
40
|
+
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* Greps a file by its content, checks if Scenario or Feature text'
|
|
44
44
|
* matches the grep text.
|
|
45
45
|
*/
|
|
46
46
|
const grepFile = (file, grep) => {
|
|
47
|
-
const contents = fs.readFileSync(file, 'utf8')
|
|
48
|
-
const pattern = new RegExp(`((Scenario|Feature)\(.*${grep}.*\))`, 'g')
|
|
49
|
-
return !!pattern.exec(contents)
|
|
50
|
-
}
|
|
47
|
+
const contents = fs.readFileSync(file, 'utf8')
|
|
48
|
+
const pattern = new RegExp(`((Scenario|Feature)\(.*${grep}.*\))`, 'g') // <- How future proof/solid is this?
|
|
49
|
+
return !!pattern.exec(contents)
|
|
50
|
+
}
|
|
51
51
|
|
|
52
|
-
const mapFileFormats =
|
|
52
|
+
const mapFileFormats = files => {
|
|
53
53
|
return {
|
|
54
54
|
gherkin: files.filter(file => file.match(/\.feature$/)),
|
|
55
55
|
js: files.filter(file => file.match(/\.t|js$/)),
|
|
56
|
-
}
|
|
57
|
-
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Creates a list of chunks incl. configuration by either dividing a list of scenario
|
|
@@ -62,30 +62,33 @@ const mapFileFormats = (files) => {
|
|
|
62
62
|
* the splitting.
|
|
63
63
|
*/
|
|
64
64
|
const createChunks = (config, patterns = []) => {
|
|
65
|
-
const files = patterns
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
const files = patterns
|
|
66
|
+
.filter(pattern => !!pattern)
|
|
67
|
+
.map(pattern => {
|
|
68
|
+
return findFiles(pattern).filter(file => {
|
|
69
|
+
return config.grep ? grepFile(file, config.grep) : true
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
.reduce((acc, val) => acc.concat(val), [])
|
|
70
73
|
|
|
71
|
-
let chunks = []
|
|
74
|
+
let chunks = []
|
|
72
75
|
if (typeof config.chunks === 'function') {
|
|
73
|
-
chunks = config.chunks.call(this, files)
|
|
76
|
+
chunks = config.chunks.call(this, files)
|
|
74
77
|
} else if (typeof config.chunks === 'number' || typeof config.chunks === 'string') {
|
|
75
|
-
chunks = splitFiles(files, Math.ceil(files.length / config.chunks))
|
|
78
|
+
chunks = splitFiles(files, Math.ceil(files.length / config.chunks))
|
|
76
79
|
} else {
|
|
77
|
-
throw new Error('chunks is neither a finite number or a valid function')
|
|
80
|
+
throw new Error('chunks is neither a finite number or a valid function')
|
|
78
81
|
}
|
|
79
82
|
|
|
80
|
-
const chunkConfig = { ...config }
|
|
81
|
-
delete chunkConfig.chunks
|
|
83
|
+
const chunkConfig = { ...config }
|
|
84
|
+
delete chunkConfig.chunks
|
|
82
85
|
|
|
83
|
-
return chunks.map(
|
|
84
|
-
const { js, gherkin } = mapFileFormats(chunkFiles)
|
|
85
|
-
return { ...chunkConfig, tests: flattenFiles(js), gherkin: { features: flattenFiles(gherkin) } }
|
|
86
|
-
})
|
|
87
|
-
}
|
|
86
|
+
return chunks.map(chunkFiles => {
|
|
87
|
+
const { js, gherkin } = mapFileFormats(chunkFiles)
|
|
88
|
+
return { ...chunkConfig, tests: flattenFiles(js), gherkin: { features: flattenFiles(gherkin) } }
|
|
89
|
+
})
|
|
90
|
+
}
|
|
88
91
|
|
|
89
|
-
|
|
90
|
-
createChunks
|
|
91
|
-
}
|
|
92
|
+
export {
|
|
93
|
+
createChunks
|
|
94
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { createChunks } from './chunk.js'
|
|
2
|
+
import { createRun } from './run.js'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Bootstraps a collection of runs, it combines user defined selection of runs
|
|
@@ -190,6 +190,6 @@ function guessBrowser(config) {
|
|
|
190
190
|
return [config.helpers[firstHelper].browser];
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
|
|
194
|
-
createRuns
|
|
195
|
-
}
|
|
193
|
+
export {
|
|
194
|
+
createRuns
|
|
195
|
+
}
|