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.
- package/README.md +0 -45
- package/bin/codecept.js +46 -57
- package/lib/actor.js +15 -11
- package/lib/ai.js +6 -5
- package/lib/assert/empty.js +9 -8
- package/lib/assert/equal.js +15 -17
- package/lib/assert/error.js +2 -2
- package/lib/assert/include.js +9 -11
- package/lib/assert/throws.js +1 -1
- package/lib/assert/truth.js +8 -5
- package/lib/assert.js +18 -18
- package/lib/codecept.js +66 -107
- package/lib/colorUtils.js +48 -50
- package/lib/command/check.js +32 -27
- package/lib/command/configMigrate.js +11 -10
- package/lib/command/definitions.js +16 -10
- package/lib/command/dryRun.js +16 -16
- package/lib/command/generate.js +29 -26
- package/lib/command/gherkin/init.js +36 -38
- package/lib/command/gherkin/snippets.js +14 -14
- package/lib/command/gherkin/steps.js +21 -18
- package/lib/command/info.js +8 -8
- package/lib/command/init.js +34 -31
- package/lib/command/interactive.js +11 -10
- package/lib/command/list.js +10 -9
- package/lib/command/run-multiple/chunk.js +5 -5
- package/lib/command/run-multiple/collection.js +5 -5
- package/lib/command/run-multiple/run.js +3 -3
- package/lib/command/run-multiple.js +16 -13
- package/lib/command/run-rerun.js +6 -7
- package/lib/command/run-workers.js +10 -24
- package/lib/command/run.js +8 -8
- package/lib/command/utils.js +20 -18
- package/lib/command/workers/runTests.js +117 -269
- package/lib/config.js +111 -49
- package/lib/container.js +299 -102
- package/lib/data/context.js +6 -5
- package/lib/data/dataScenarioConfig.js +1 -1
- package/lib/data/dataTableArgument.js +1 -1
- package/lib/data/table.js +1 -1
- package/lib/effects.js +94 -10
- package/lib/els.js +11 -9
- package/lib/event.js +11 -10
- package/lib/globals.js +141 -0
- package/lib/heal.js +12 -12
- package/lib/helper/AI.js +1 -1
- package/lib/helper/ApiDataFactory.js +16 -13
- package/lib/helper/FileSystem.js +32 -12
- package/lib/helper/GraphQL.js +1 -1
- package/lib/helper/GraphQLDataFactory.js +1 -1
- package/lib/helper/JSONResponse.js +19 -30
- package/lib/helper/Mochawesome.js +9 -28
- package/lib/helper/Playwright.js +668 -265
- package/lib/helper/Puppeteer.js +284 -169
- package/lib/helper/REST.js +29 -12
- package/lib/helper/WebDriver.js +192 -71
- 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 +1 -1
- 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 +6 -7
- package/lib/listener/exit.js +4 -3
- package/lib/listener/globalRetry.js +5 -5
- package/lib/listener/globalTimeout.js +11 -10
- package/lib/listener/helpers.js +33 -14
- package/lib/listener/mocha.js +3 -4
- package/lib/listener/result.js +4 -5
- package/lib/listener/steps.js +7 -18
- package/lib/listener/store.js +3 -3
- package/lib/locator.js +213 -192
- package/lib/mocha/asyncWrapper.js +108 -75
- package/lib/mocha/bdd.js +99 -13
- package/lib/mocha/cli.js +60 -27
- package/lib/mocha/factory.js +75 -19
- package/lib/mocha/featureConfig.js +1 -1
- package/lib/mocha/gherkin.js +57 -25
- package/lib/mocha/hooks.js +12 -3
- package/lib/mocha/index.js +13 -4
- package/lib/mocha/inject.js +22 -5
- package/lib/mocha/scenarioConfig.js +2 -2
- package/lib/mocha/suite.js +9 -2
- package/lib/mocha/test.js +10 -13
- package/lib/mocha/ui.js +28 -31
- package/lib/output.js +11 -9
- package/lib/parser.js +44 -44
- package/lib/pause.js +15 -16
- package/lib/plugin/analyze.js +19 -12
- package/lib/plugin/auth.js +20 -21
- package/lib/plugin/autoDelay.js +12 -8
- package/lib/plugin/coverage.js +12 -8
- package/lib/plugin/customLocator.js +3 -3
- package/lib/plugin/customReporter.js +3 -2
- package/lib/plugin/heal.js +14 -9
- package/lib/plugin/pageInfo.js +10 -10
- package/lib/plugin/pauseOnFail.js +4 -3
- package/lib/plugin/retryFailedStep.js +47 -5
- package/lib/plugin/screenshotOnFail.js +75 -37
- package/lib/plugin/stepByStepReport.js +14 -14
- package/lib/plugin/stepTimeout.js +4 -3
- package/lib/plugin/subtitles.js +6 -5
- package/lib/recorder.js +33 -23
- package/lib/rerun.js +69 -26
- package/lib/result.js +4 -4
- package/lib/secret.js +18 -17
- package/lib/session.js +95 -89
- package/lib/step/base.js +6 -6
- package/lib/step/config.js +1 -1
- package/lib/step/func.js +3 -3
- package/lib/step/helper.js +3 -3
- package/lib/step/meta.js +4 -4
- package/lib/step/record.js +11 -11
- package/lib/step/retry.js +3 -3
- package/lib/step/section.js +3 -3
- package/lib/step.js +7 -10
- package/lib/steps.js +9 -5
- package/lib/store.js +1 -1
- package/lib/timeout.js +1 -7
- package/lib/transform.js +8 -8
- package/lib/translation.js +32 -18
- package/lib/utils.js +68 -97
- package/lib/workerStorage.js +16 -17
- package/lib/workers.js +145 -171
- package/package.json +58 -55
- package/translations/de-DE.js +2 -2
- package/translations/fr-FR.js +2 -2
- package/translations/index.js +23 -10
- package/translations/it-IT.js +2 -2
- package/translations/ja-JP.js +2 -2
- package/translations/nl-NL.js +2 -2
- package/translations/pl-PL.js +2 -2
- package/translations/pt-BR.js +2 -2
- package/translations/ru-RU.js +2 -2
- package/translations/utils.js +4 -3
- package/translations/zh-CN.js +2 -2
- package/translations/zh-TW.js +2 -2
- package/typings/index.d.ts +7 -18
- package/typings/promiseBasedTypes.d.ts +3769 -5450
- package/typings/types.d.ts +3953 -5778
- package/bin/test-server.js +0 -53
- package/lib/element/WebElement.js +0 -327
- package/lib/helper/Nightmare.js +0 -1486
- package/lib/helper/Protractor.js +0 -1840
- package/lib/helper/TestCafe.js +0 -1391
- 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 -61
- package/lib/listener/retryEnhancer.js +0 -85
- package/lib/plugin/allure.js +0 -15
- package/lib/plugin/autoLogin.js +0 -5
- package/lib/plugin/commentStep.js +0 -141
- package/lib/plugin/eachElement.js +0 -127
- package/lib/plugin/fakerTransform.js +0 -49
- package/lib/plugin/htmlReporter.js +0 -1947
- package/lib/plugin/retryTo.js +0 -16
- package/lib/plugin/selenoid.js +0 -364
- package/lib/plugin/standardActingHelpers.js +0 -6
- package/lib/plugin/tryTo.js +0 -16
- package/lib/plugin/wdio.js +0 -247
- package/lib/test-server.js +0 -323
- package/lib/within.js +0 -90
package/lib/command/generate.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 { fileExists, ucfirst, lcfirst, beautify } from '../utils.js'
|
|
7
|
+
import output from '../output.js'
|
|
8
|
+
import generateDefinitions from './definitions.js'
|
|
9
|
+
import { getConfig, getTestRoot, safeFileWrite, readConfig } from './utils.js'
|
|
10
10
|
|
|
11
11
|
let extension = 'js'
|
|
12
12
|
|
|
@@ -18,10 +18,10 @@ Scenario('test something', async ({ {{actor}} }) => {
|
|
|
18
18
|
`
|
|
19
19
|
|
|
20
20
|
// generates empty test
|
|
21
|
-
|
|
21
|
+
export async function test(genPath) {
|
|
22
22
|
const testsPath = getTestRoot(genPath)
|
|
23
23
|
global.codecept_dir = testsPath
|
|
24
|
-
const config = getConfig(testsPath)
|
|
24
|
+
const config = await getConfig(testsPath)
|
|
25
25
|
if (!config) return
|
|
26
26
|
|
|
27
27
|
output.print('Creating a new test...')
|
|
@@ -46,7 +46,7 @@ module.exports.test = function (genPath) {
|
|
|
46
46
|
},
|
|
47
47
|
},
|
|
48
48
|
])
|
|
49
|
-
.then(result => {
|
|
49
|
+
.then(async result => {
|
|
50
50
|
const testFilePath = path.dirname(path.join(testsPath, config.tests)).replace(/\*\*$/, '')
|
|
51
51
|
let testFile = path.join(testFilePath, result.filename)
|
|
52
52
|
const ext = path.extname(testFile)
|
|
@@ -55,8 +55,9 @@ module.exports.test = function (genPath) {
|
|
|
55
55
|
if (!fileExists(dir)) mkdirp.sync(dir)
|
|
56
56
|
let testContent = testTemplate.replace('{{feature}}', result.feature)
|
|
57
57
|
|
|
58
|
-
const
|
|
59
|
-
container.
|
|
58
|
+
const containerModule = await import('../container.js')
|
|
59
|
+
const container = containerModule.default || containerModule
|
|
60
|
+
await container.create(config, {})
|
|
60
61
|
// translate scenario test
|
|
61
62
|
if (container.translation().loaded) {
|
|
62
63
|
const vocabulary = container.translation().vocabulary
|
|
@@ -76,7 +77,7 @@ module.exports.test = function (genPath) {
|
|
|
76
77
|
|
|
77
78
|
const pageObjectTemplate = `const { I } = inject();
|
|
78
79
|
|
|
79
|
-
|
|
80
|
+
export default {
|
|
80
81
|
|
|
81
82
|
// insert your locators and methods here
|
|
82
83
|
}
|
|
@@ -101,13 +102,13 @@ class {{name}} {
|
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
// For inheritance
|
|
104
|
-
|
|
105
|
-
export
|
|
105
|
+
export default new {{name}}();
|
|
106
|
+
export { {{name}} };
|
|
106
107
|
`
|
|
107
108
|
|
|
108
|
-
|
|
109
|
+
export async function pageObject(genPath, opts) {
|
|
109
110
|
const testsPath = getTestRoot(genPath)
|
|
110
|
-
const config = getConfig(testsPath)
|
|
111
|
+
const config = await getConfig(testsPath)
|
|
111
112
|
const kind = opts.T || 'page'
|
|
112
113
|
if (!config) return
|
|
113
114
|
|
|
@@ -155,7 +156,7 @@ module.exports.pageObject = function (genPath, opts) {
|
|
|
155
156
|
// relative path
|
|
156
157
|
actorPath = path.relative(dir, path.dirname(path.join(testsPath, actorPath))) + actorPath.substring(1) // get an upper level
|
|
157
158
|
}
|
|
158
|
-
actor = `
|
|
159
|
+
actor = `import('${actorPath}')`
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
const name = lcfirst(result.name) + ucfirst(kind)
|
|
@@ -197,7 +198,7 @@ module.exports.pageObject = function (genPath, opts) {
|
|
|
197
198
|
})
|
|
198
199
|
}
|
|
199
200
|
|
|
200
|
-
const helperTemplate = `
|
|
201
|
+
const helperTemplate = `import Helper from '@codeceptjs/helper';
|
|
201
202
|
|
|
202
203
|
class {{name}} extends Helper {
|
|
203
204
|
|
|
@@ -222,10 +223,10 @@ class {{name}} extends Helper {
|
|
|
222
223
|
|
|
223
224
|
}
|
|
224
225
|
|
|
225
|
-
|
|
226
|
+
export default {{name}};
|
|
226
227
|
`
|
|
227
228
|
|
|
228
|
-
|
|
229
|
+
export async function helper(genPath) {
|
|
229
230
|
const testsPath = getTestRoot(genPath)
|
|
230
231
|
|
|
231
232
|
output.print('Creating a new helper')
|
|
@@ -265,9 +266,11 @@ helpers: {
|
|
|
265
266
|
})
|
|
266
267
|
}
|
|
267
268
|
|
|
269
|
+
import { fileURLToPath } from 'url'
|
|
270
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
268
271
|
const healTemplate = fs.readFileSync(path.join(__dirname, '../template/heal.js'), 'utf8').toString()
|
|
269
272
|
|
|
270
|
-
|
|
273
|
+
export async function heal(genPath) {
|
|
271
274
|
const testsPath = getTestRoot(genPath)
|
|
272
275
|
|
|
273
276
|
let configFile = path.join(testsPath, `codecept.conf.${extension}`)
|
|
@@ -282,9 +285,9 @@ module.exports.heal = function (genPath) {
|
|
|
282
285
|
output.print('Require this file in the config file and enable heal plugin:')
|
|
283
286
|
output.print('--------------------------')
|
|
284
287
|
output.print(`
|
|
285
|
-
|
|
288
|
+
import './heal.js'
|
|
286
289
|
|
|
287
|
-
|
|
290
|
+
export const config = {
|
|
288
291
|
// ...
|
|
289
292
|
plugins: {
|
|
290
293
|
heal: {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import { mkdirp } from 'mkdirp'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
getConfig, getTestRoot, updateConfig, safeFileWrite, findConfigFile,
|
|
8
|
-
} = require('../utils');
|
|
4
|
+
import output from '../../output.js'
|
|
5
|
+
import { fileExists } from '../../utils.js'
|
|
6
|
+
import { getConfig, getTestRoot, updateConfig, safeFileWrite, findConfigFile } from '../utils.js'
|
|
9
7
|
|
|
10
8
|
const featureFile = `Feature: Business rules
|
|
11
9
|
In order to achieve my goals
|
|
@@ -14,7 +12,7 @@ const featureFile = `Feature: Business rules
|
|
|
14
12
|
|
|
15
13
|
Scenario: do something
|
|
16
14
|
Given I have a defined step
|
|
17
|
-
|
|
15
|
+
`
|
|
18
16
|
|
|
19
17
|
const stepsFile = `const { I } = inject();
|
|
20
18
|
// Add in your custom step files
|
|
@@ -22,60 +20,60 @@ const stepsFile = `const { I } = inject();
|
|
|
22
20
|
Given('I have a defined step', () => {
|
|
23
21
|
// TODO: replace with your own step
|
|
24
22
|
});
|
|
25
|
-
|
|
23
|
+
`
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
const testsPath = getTestRoot(genPath)
|
|
29
|
-
const configFile = findConfigFile(testsPath)
|
|
25
|
+
export default async function (genPath) {
|
|
26
|
+
const testsPath = getTestRoot(genPath)
|
|
27
|
+
const configFile = findConfigFile(testsPath)
|
|
30
28
|
|
|
31
29
|
if (!configFile) {
|
|
32
|
-
output.error(
|
|
33
|
-
|
|
34
|
-
);
|
|
35
|
-
process.exit(1);
|
|
30
|
+
output.error("Can't initialize Gherkin. This command must be run in an already initialized project.")
|
|
31
|
+
process.exit(1)
|
|
36
32
|
}
|
|
37
33
|
|
|
38
|
-
const config = getConfig(testsPath)
|
|
39
|
-
const extension = path.extname(configFile).substring(1)
|
|
34
|
+
const config = await getConfig(testsPath)
|
|
35
|
+
const extension = path.extname(configFile).substring(1)
|
|
40
36
|
|
|
41
|
-
output.print('Initializing Gherkin (Cucumber BDD) for CodeceptJS')
|
|
42
|
-
output.print('--------------------------')
|
|
37
|
+
output.print('Initializing Gherkin (Cucumber BDD) for CodeceptJS')
|
|
38
|
+
output.print('--------------------------')
|
|
43
39
|
|
|
44
40
|
if (config.gherkin && config.gherkin.steps) {
|
|
45
|
-
output.error('Gherkin is already initialized in this project. See `gherkin` section in the config')
|
|
46
|
-
process.exit(1)
|
|
41
|
+
output.error('Gherkin is already initialized in this project. See `gherkin` section in the config')
|
|
42
|
+
process.exit(1)
|
|
47
43
|
}
|
|
48
44
|
|
|
49
|
-
let dir
|
|
50
|
-
dir = path.join(testsPath, 'features')
|
|
45
|
+
let dir
|
|
46
|
+
dir = path.join(testsPath, 'features')
|
|
51
47
|
if (!fileExists(dir)) {
|
|
52
|
-
mkdirp.sync(dir)
|
|
53
|
-
|
|
48
|
+
mkdirp.sync(dir)
|
|
49
|
+
// Use relative path for output
|
|
50
|
+
const relativeDir = path.relative(process.cwd(), dir)
|
|
51
|
+
output.success(`Created ${relativeDir}, place your *.feature files in it`)
|
|
54
52
|
}
|
|
55
53
|
|
|
56
54
|
if (safeFileWrite(path.join(dir, 'basic.feature'), featureFile)) {
|
|
57
|
-
output.success('Created sample feature file: features/basic.feature')
|
|
55
|
+
output.success('Created sample feature file: features/basic.feature')
|
|
58
56
|
}
|
|
59
57
|
|
|
60
|
-
dir = path.join(testsPath, 'step_definitions')
|
|
58
|
+
dir = path.join(testsPath, 'step_definitions')
|
|
61
59
|
if (!fileExists(dir)) {
|
|
62
|
-
mkdirp.sync(dir)
|
|
63
|
-
|
|
60
|
+
mkdirp.sync(dir)
|
|
61
|
+
// Use relative path for output
|
|
62
|
+
const relativeDir = path.relative(process.cwd(), dir)
|
|
63
|
+
output.success(`Created ${relativeDir}, place step definitions into it`)
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
if (safeFileWrite(path.join(dir, `steps.${extension}`), stepsFile)) {
|
|
67
|
-
output.success(
|
|
68
|
-
`Created sample steps file: step_definitions/steps.${extension}`,
|
|
69
|
-
);
|
|
67
|
+
output.success(`Created sample steps file: step_definitions/steps.${extension}`)
|
|
70
68
|
}
|
|
71
69
|
|
|
72
70
|
config.gherkin = {
|
|
73
71
|
features: './features/*.feature',
|
|
74
72
|
steps: [`./step_definitions/steps.${extension}`],
|
|
75
|
-
}
|
|
73
|
+
}
|
|
76
74
|
|
|
77
|
-
updateConfig(testsPath, config, extension)
|
|
75
|
+
updateConfig(testsPath, config, extension)
|
|
78
76
|
|
|
79
|
-
output.success('Gherkin setup is done.')
|
|
80
|
-
output.success('Start writing feature files and implement corresponding steps.')
|
|
81
|
-
}
|
|
77
|
+
output.success('Gherkin setup is done.')
|
|
78
|
+
output.success('Start writing feature files and implement corresponding steps.')
|
|
79
|
+
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import escapeStringRegexp from 'escape-string-regexp'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import Gherkin from '@cucumber/gherkin'
|
|
4
|
+
import { IdGenerator } from '@cucumber/messages'
|
|
5
|
+
import { globSync } from 'glob'
|
|
6
|
+
import fsPath from 'path'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import { getConfig, getTestRoot } from '../utils.js'
|
|
9
|
+
import Codecept from '../../codecept.js'
|
|
10
|
+
import output from '../../output.js'
|
|
11
|
+
import { matchStep } from '../../mocha/bdd.js'
|
|
12
12
|
|
|
13
|
-
const uuidFn =
|
|
13
|
+
const uuidFn = IdGenerator.uuid()
|
|
14
14
|
const builder = new Gherkin.AstBuilder(uuidFn)
|
|
15
15
|
const matcher = new Gherkin.GherkinClassicTokenMatcher()
|
|
16
16
|
const parser = new Gherkin.Parser(builder, matcher)
|
|
17
17
|
parser.stopAtFirstError = false
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
export default async function (genPath, options) {
|
|
20
20
|
const configFile = options.config || genPath
|
|
21
21
|
const testsPath = getTestRoot(configFile)
|
|
22
|
-
const config = getConfig(configFile)
|
|
22
|
+
const config = await getConfig(configFile)
|
|
23
23
|
if (!config) return
|
|
24
24
|
|
|
25
25
|
const codecept = new Codecept(config, {})
|
|
26
|
-
codecept.init(testsPath)
|
|
26
|
+
await codecept.init(testsPath)
|
|
27
27
|
|
|
28
28
|
if (!config.gherkin) {
|
|
29
29
|
output.error('Gherkin is not enabled in config. Run `codecept gherkin:init` to enable it')
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { getConfig, getTestRoot } from '../utils.js'
|
|
2
|
+
import Codecept from '../../codecept.js'
|
|
3
|
+
import output from '../../output.js'
|
|
4
|
+
import { getSteps, clearSteps } from '../../mocha/bdd.js'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
const configFile = options.config || genPath
|
|
8
|
-
const testsPath = getTestRoot(configFile)
|
|
9
|
-
const config = getConfig(configFile)
|
|
10
|
-
if (!config) return
|
|
6
|
+
export default async function (genPath, options) {
|
|
7
|
+
const configFile = options.config || genPath
|
|
8
|
+
const testsPath = getTestRoot(configFile)
|
|
9
|
+
const config = await getConfig(configFile)
|
|
10
|
+
if (!config) return
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
// Clear any previously loaded steps
|
|
13
|
+
clearSteps()
|
|
14
|
+
|
|
15
|
+
const codecept = new Codecept(config, {})
|
|
16
|
+
await codecept.init(testsPath)
|
|
14
17
|
|
|
15
|
-
output.print('Gherkin Step Definitions:')
|
|
16
|
-
output.print()
|
|
17
|
-
const steps = getSteps()
|
|
18
|
+
output.print('Gherkin Step Definitions:')
|
|
19
|
+
output.print()
|
|
20
|
+
const steps = getSteps()
|
|
18
21
|
for (const step of Object.keys(steps)) {
|
|
19
|
-
output.print(` ${output.colors.bold(step)} ${output.colors.green(steps[step].line || '')}`)
|
|
22
|
+
output.print(` ${output.colors.bold(step)} ${output.colors.green(steps[step].line || '')}`)
|
|
20
23
|
}
|
|
21
|
-
output.print()
|
|
24
|
+
output.print()
|
|
22
25
|
if (!Object.keys(steps).length) {
|
|
23
|
-
output.error('No Gherkin steps defined')
|
|
26
|
+
output.error('No Gherkin steps defined')
|
|
24
27
|
}
|
|
25
|
-
}
|
|
28
|
+
}
|
package/lib/command/info.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import envinfo from 'envinfo'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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'
|
|
7
7
|
|
|
8
8
|
async function getPlaywrightBrowsers() {
|
|
9
9
|
try {
|
|
@@ -40,9 +40,9 @@ async function getOsBrowsers() {
|
|
|
40
40
|
].join(', ')
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
export default async function (path) {
|
|
44
44
|
const testsPath = getTestRoot(path)
|
|
45
|
-
const config = getConfig(testsPath)
|
|
45
|
+
const config = await getConfig(testsPath)
|
|
46
46
|
const codecept = new Codecept(config, {})
|
|
47
47
|
codecept.init(testsPath)
|
|
48
48
|
|
|
@@ -73,7 +73,7 @@ module.exports = async function (path) {
|
|
|
73
73
|
output.print('***************************************')
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
export const getMachineInfo = async () => {
|
|
77
77
|
const info = {
|
|
78
78
|
nodeInfo: await envinfo.helpers.getNodeInfo(),
|
|
79
79
|
osInfo: await envinfo.helpers.getOSInfo(),
|
package/lib/command/init.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
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',
|
|
18
19
|
output: '',
|
|
19
20
|
helpers: {},
|
|
20
21
|
include: {},
|
|
21
|
-
plugins: {
|
|
22
|
-
htmlReporter: {
|
|
23
|
-
enabled: true,
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
22
|
}
|
|
27
23
|
|
|
28
|
-
const helpers = ['Playwright', 'WebDriver', 'Puppeteer', 'REST', 'GraphQL', 'Appium'
|
|
29
|
-
const translations = Object.keys(require('../../translations'))
|
|
30
|
-
|
|
24
|
+
const helpers = ['Playwright', 'WebDriver', 'Puppeteer', 'REST', 'GraphQL', 'Appium']
|
|
31
25
|
const noTranslation = 'English (no localization)'
|
|
32
|
-
|
|
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
|
+
}
|
|
33
33
|
|
|
34
34
|
const packages = []
|
|
35
35
|
let isTypeScript = false
|
|
@@ -50,7 +50,7 @@ setCommonPlugins();
|
|
|
50
50
|
|
|
51
51
|
const defaultActor = `// in this file you can append custom step methods to 'I' object
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
export default function() {
|
|
54
54
|
return actor({
|
|
55
55
|
|
|
56
56
|
// Define custom steps here, use 'this' to access default methods of I.
|
|
@@ -72,8 +72,9 @@ export = function() {
|
|
|
72
72
|
}
|
|
73
73
|
`
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
export default async function (initPath) {
|
|
76
76
|
const testsPath = getTestRoot(initPath)
|
|
77
|
+
const translations = await getTranslations()
|
|
77
78
|
|
|
78
79
|
print()
|
|
79
80
|
print(` Welcome to ${colors.magenta.bold('CodeceptJS')} initialization tool`)
|
|
@@ -151,7 +152,7 @@ module.exports = function (initPath) {
|
|
|
151
152
|
choices: translations,
|
|
152
153
|
},
|
|
153
154
|
])
|
|
154
|
-
.then(result => {
|
|
155
|
+
.then(async result => {
|
|
155
156
|
if (result.typescript === true) {
|
|
156
157
|
isTypeScript = true
|
|
157
158
|
extension = isTypeScript === true ? 'ts' : 'js'
|
|
@@ -187,7 +188,8 @@ module.exports = function (initPath) {
|
|
|
187
188
|
let helperConfigs = []
|
|
188
189
|
|
|
189
190
|
try {
|
|
190
|
-
const
|
|
191
|
+
const HelperModule = await import(`../helper/${helperName}.js`)
|
|
192
|
+
const Helper = HelperModule.default || HelperModule
|
|
191
193
|
if (Helper._checkRequirements) {
|
|
192
194
|
packages.concat(Helper._checkRequirements())
|
|
193
195
|
}
|
|
@@ -212,9 +214,9 @@ module.exports = function (initPath) {
|
|
|
212
214
|
fs.writeFileSync(path.join(testsPath, stepFile), extension === 'ts' ? defaultActorTs : defaultActor)
|
|
213
215
|
|
|
214
216
|
if (isTypeScript) {
|
|
215
|
-
config.include = _actorTranslation('./steps_file', config.translation)
|
|
217
|
+
config.include = await _actorTranslation('./steps_file', config.translation, translations)
|
|
216
218
|
} else {
|
|
217
|
-
config.include = _actorTranslation(stepFile, config.translation)
|
|
219
|
+
config.include = await _actorTranslation(stepFile, config.translation, translations)
|
|
218
220
|
}
|
|
219
221
|
|
|
220
222
|
print(`Steps file created at ${stepFile}`)
|
|
@@ -395,7 +397,7 @@ function install(dependencies) {
|
|
|
395
397
|
return true
|
|
396
398
|
}
|
|
397
399
|
|
|
398
|
-
function _actorTranslation(stepFile, translationSelected) {
|
|
400
|
+
async function _actorTranslation(stepFile, translationSelected, translations) {
|
|
399
401
|
let actor
|
|
400
402
|
|
|
401
403
|
for (const translationAvailable of translations) {
|
|
@@ -404,7 +406,8 @@ function _actorTranslation(stepFile, translationSelected) {
|
|
|
404
406
|
}
|
|
405
407
|
|
|
406
408
|
if (translationSelected === translationAvailable) {
|
|
407
|
-
const
|
|
409
|
+
const translationsModule = await import('../../translations/index.js')
|
|
410
|
+
const nameOfActor = (translationsModule.default || translationsModule)[translationAvailable].I
|
|
408
411
|
|
|
409
412
|
actor = {
|
|
410
413
|
[nameOfActor]: stepFile,
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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'
|
|
7
8
|
const webHelpers = Container.STANDARD_ACTING_HELPERS
|
|
8
9
|
|
|
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,6 +21,7 @@ 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
|
|
|
@@ -51,8 +53,7 @@ module.exports = async function (path, options) {
|
|
|
51
53
|
break
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
|
-
|
|
55
|
-
// recorder.catchWithoutStop((err) => console.log(err.stack));
|
|
56
|
+
pause()
|
|
56
57
|
recorder.add(() => event.emit(event.test.after, {}))
|
|
57
58
|
recorder.add(() => event.emit(event.suite.after, {}))
|
|
58
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()
|
|
@@ -1,6 +1,6 @@
|
|
|
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.
|
|
@@ -89,6 +89,6 @@ const createChunks = (config, patterns = []) => {
|
|
|
89
89
|
})
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
createChunks
|
|
92
|
+
export {
|
|
93
|
+
createChunks
|
|
94
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
|
+
}
|