codeceptjs 4.0.0-beta.2 → 4.0.0-beta.4
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 +2 -2
- package/bin/codecept.js +84 -81
- package/lib/actor.js +13 -13
- package/lib/ai.js +10 -13
- package/lib/assert/empty.js +20 -21
- package/lib/assert/equal.js +37 -39
- package/lib/assert/error.js +14 -14
- package/lib/assert/include.js +46 -47
- package/lib/assert/throws.js +13 -11
- package/lib/assert/truth.js +19 -22
- package/lib/assert.js +4 -2
- package/lib/cli.js +56 -49
- package/lib/codecept.js +145 -155
- package/lib/colorUtils.js +3 -3
- package/lib/command/configMigrate.js +58 -52
- package/lib/command/definitions.js +88 -89
- package/lib/command/dryRun.js +79 -81
- package/lib/command/generate.js +197 -188
- package/lib/command/gherkin/init.js +27 -16
- package/lib/command/gherkin/snippets.js +21 -21
- package/lib/command/gherkin/steps.js +8 -8
- package/lib/command/info.js +40 -38
- package/lib/command/init.js +290 -288
- package/lib/command/interactive.js +32 -32
- package/lib/command/list.js +26 -26
- package/lib/command/run-multiple/chunk.js +5 -5
- package/lib/command/run-multiple/collection.js +3 -3
- package/lib/command/run-multiple/run.js +6 -2
- package/lib/command/run-multiple.js +113 -93
- package/lib/command/run-rerun.js +20 -25
- package/lib/command/run-workers.js +64 -66
- package/lib/command/run.js +26 -29
- package/lib/command/utils.js +80 -65
- package/lib/command/workers/runTests.js +11 -12
- package/lib/config.js +10 -9
- package/lib/container.js +40 -48
- package/lib/data/context.js +60 -59
- package/lib/data/dataScenarioConfig.js +47 -47
- package/lib/data/dataTableArgument.js +29 -29
- package/lib/data/table.js +26 -20
- package/lib/event.js +163 -167
- package/lib/heal.js +14 -18
- package/lib/helper/AI.js +130 -41
- package/lib/helper/ApiDataFactory.js +74 -70
- package/lib/helper/Appium.js +416 -388
- package/lib/helper/ExpectHelper.js +40 -48
- package/lib/helper/FileSystem.js +80 -79
- package/lib/helper/GraphQL.js +44 -43
- package/lib/helper/GraphQLDataFactory.js +51 -51
- package/lib/helper/JSONResponse.js +65 -62
- package/lib/helper/Mochawesome.js +28 -28
- package/lib/helper/Nightmare.js +664 -571
- package/lib/helper/Playwright.js +1367 -1222
- package/lib/helper/Protractor.js +663 -635
- package/lib/helper/Puppeteer.js +1232 -1132
- package/lib/helper/REST.js +183 -68
- package/lib/helper/SoftExpectHelper.js +2 -2
- package/lib/helper/TestCafe.js +490 -486
- package/lib/helper/WebDriver.js +1246 -1297
- package/lib/helper/clientscripts/PollyWebDriverExt.js +1 -1
- package/lib/helper/errors/ConnectionRefused.js +1 -1
- package/lib/helper/errors/ElementAssertion.js +2 -2
- package/lib/helper/errors/ElementNotFound.js +2 -2
- package/lib/helper/errors/RemoteBrowserConnectionRefused.js +1 -1
- package/lib/helper/extras/Console.js +1 -1
- package/lib/helper/extras/PlaywrightPropEngine.js +4 -4
- package/lib/helper/extras/PlaywrightReactVueLocator.js +1 -1
- package/lib/helper/extras/PlaywrightRestartOpts.js +21 -18
- package/lib/helper/extras/Popup.js +1 -1
- package/lib/helper/extras/React.js +3 -3
- package/lib/helper/network/actions.js +14 -7
- package/lib/helper/network/utils.js +4 -3
- package/lib/helper/scripts/blurElement.js +1 -1
- package/lib/helper/scripts/focusElement.js +1 -1
- package/lib/helper/scripts/highlightElement.js +1 -1
- package/lib/helper/scripts/isElementClickable.js +1 -1
- package/lib/helper/testcafe/testControllerHolder.js +1 -1
- package/lib/helper/testcafe/testcafe-utils.js +7 -8
- package/lib/helper.js +1 -3
- package/lib/history.js +6 -5
- package/lib/hooks.js +6 -6
- package/lib/html.js +7 -7
- package/lib/index.js +25 -41
- package/lib/interfaces/bdd.js +47 -64
- package/lib/interfaces/featureConfig.js +19 -19
- package/lib/interfaces/gherkin.js +124 -118
- package/lib/interfaces/scenarioConfig.js +29 -29
- package/lib/listener/artifacts.js +9 -9
- package/lib/listener/config.js +24 -24
- package/lib/listener/exit.js +12 -12
- package/lib/listener/helpers.js +42 -42
- package/lib/listener/mocha.js +11 -11
- package/lib/listener/retry.js +32 -30
- package/lib/listener/steps.js +50 -53
- package/lib/listener/timeout.js +54 -54
- package/lib/locator.js +7 -11
- package/lib/mochaFactory.js +18 -15
- package/lib/output.js +19 -15
- package/lib/parser.js +15 -12
- package/lib/pause.js +45 -38
- package/lib/plugin/allure.js +15 -15
- package/lib/plugin/autoDelay.js +29 -37
- package/lib/plugin/autoLogin.js +70 -65
- package/lib/plugin/commentStep.js +18 -18
- package/lib/plugin/coverage.js +112 -67
- package/lib/plugin/customLocator.js +21 -20
- package/lib/plugin/debugErrors.js +24 -24
- package/lib/plugin/eachElement.js +38 -38
- package/lib/plugin/fakerTransform.js +6 -6
- package/lib/plugin/heal.js +67 -108
- package/lib/plugin/pauseOnFail.js +11 -11
- package/lib/plugin/retryFailedStep.js +32 -39
- package/lib/plugin/retryTo.js +46 -40
- package/lib/plugin/screenshotOnFail.js +109 -87
- package/lib/plugin/selenoid.js +131 -118
- package/lib/plugin/standardActingHelpers.js +2 -8
- package/lib/plugin/stepByStepReport.js +110 -91
- package/lib/plugin/stepTimeout.js +24 -23
- package/lib/plugin/subtitles.js +34 -35
- package/lib/plugin/tryTo.js +40 -30
- package/lib/plugin/wdio.js +78 -75
- package/lib/recorder.js +14 -17
- package/lib/rerun.js +11 -10
- package/lib/scenario.js +25 -23
- package/lib/secret.js +4 -3
- package/lib/session.js +10 -10
- package/lib/step.js +12 -9
- package/lib/store.js +2 -3
- package/lib/transform.js +1 -1
- package/lib/translation.js +7 -8
- package/lib/ui.js +12 -14
- package/lib/utils.js +70 -72
- package/lib/within.js +10 -10
- package/lib/workerStorage.js +27 -25
- package/lib/workers.js +29 -33
- package/package.json +67 -68
- package/translations/de-DE.js +2 -1
- package/translations/fr-FR.js +2 -2
- package/translations/index.js +9 -13
- package/translations/it-IT.js +1 -1
- package/translations/ja-JP.js +1 -1
- package/translations/pl-PL.js +1 -1
- package/translations/pt-BR.js +1 -1
- package/translations/ru-RU.js +1 -1
- package/translations/zh-CN.js +1 -1
- package/translations/zh-TW.js +1 -1
- package/typings/index.d.ts +423 -65
- package/typings/promiseBasedTypes.d.ts +41 -172
- package/typings/types.d.ts +43 -178
- package/lib/dirname.js +0 -5
- package/lib/helper/Expect.js +0 -425
- package/lib/helper/MockServer.js +0 -223
package/README.md
CHANGED
|
@@ -312,17 +312,17 @@ Thanks all to those who are and will have contributing to this awesome project!
|
|
|
312
312
|
<a href="https://github.com/tsuemura"><img src="https://avatars.githubusercontent.com/u/17092259?v=4" title="tsuemura" width="80" height="80"></a>
|
|
313
313
|
<a href="https://github.com/EgorBodnar"><img src="https://avatars.githubusercontent.com/u/63167966?v=4" title="EgorBodnar" width="80" height="80"></a>
|
|
314
314
|
<a href="https://github.com/VikalpP"><img src="https://avatars.githubusercontent.com/u/11846339?v=4" title="VikalpP" width="80" height="80"></a>
|
|
315
|
+
<a href="https://github.com/thomashohn"><img src="https://avatars.githubusercontent.com/u/3414869?v=4" title="thomashohn" width="80" height="80"></a>
|
|
315
316
|
<a href="https://github.com/elaichenkov"><img src="https://avatars.githubusercontent.com/u/29764053?v=4" title="elaichenkov" width="80" height="80"></a>
|
|
316
317
|
<a href="https://github.com/BorisOsipov"><img src="https://avatars.githubusercontent.com/u/6514276?v=4" title="BorisOsipov" width="80" height="80"></a>
|
|
318
|
+
<a href="https://github.com/ngraf"><img src="https://avatars.githubusercontent.com/u/7094389?v=4" title="ngraf" width="80" height="80"></a>
|
|
317
319
|
<a href="https://github.com/nitschSB"><img src="https://avatars.githubusercontent.com/u/39341455?v=4" title="nitschSB" width="80" height="80"></a>
|
|
318
320
|
<a href="https://github.com/hubidu"><img src="https://avatars.githubusercontent.com/u/13134082?v=4" title="hubidu" width="80" height="80"></a>
|
|
319
321
|
<a href="https://github.com/jploskonka"><img src="https://avatars.githubusercontent.com/u/669483?v=4" title="jploskonka" width="80" height="80"></a>
|
|
320
|
-
<a href="https://github.com/ngraf"><img src="https://avatars.githubusercontent.com/u/7094389?v=4" title="ngraf" width="80" height="80"></a>
|
|
321
322
|
<a href="https://github.com/maojunxyz"><img src="https://avatars.githubusercontent.com/u/28778042?v=4" title="maojunxyz" width="80" height="80"></a>
|
|
322
323
|
<a href="https://github.com/abhimanyupandian"><img src="https://avatars.githubusercontent.com/u/36107381?v=4" title="abhimanyupandian" width="80" height="80"></a>
|
|
323
324
|
<a href="https://github.com/martomo"><img src="https://avatars.githubusercontent.com/u/1850135?v=4" title="martomo" width="80" height="80"></a>
|
|
324
325
|
<a href="https://github.com/hatufacci"><img src="https://avatars.githubusercontent.com/u/4963181?v=4" title="hatufacci" width="80" height="80"></a>
|
|
325
|
-
<a href="https://github.com/johnyb"><img src="https://avatars.githubusercontent.com/u/86358?v=4" title="johnyb" width="80" height="80"></a>
|
|
326
326
|
|
|
327
327
|
[//]: contributor-faces
|
|
328
328
|
|
package/bin/codecept.js
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import * as init from '../lib/command/init.js';
|
|
7
|
-
import * as configMigrate from '../lib/command/configMigrate.js';
|
|
8
|
-
import * as interactive from '../lib/command/interactive.js';
|
|
9
|
-
import * as definitions from '../lib/command/definitions.js';
|
|
10
|
-
import * as list from '../lib/command/list.js';
|
|
11
|
-
import * as gherkinInit from '../lib/command/gherkin/init.js';
|
|
12
|
-
import * as gherkinSteps from '../lib/command/gherkin/steps.js';
|
|
13
|
-
import * as gherkinSnippets from '../lib/command/gherkin/snippets.js';
|
|
14
|
-
import * as generate from '../lib/command/generate.js';
|
|
15
|
-
import * as run from '../lib/command/run.js';
|
|
16
|
-
import * as runWorkers from '../lib/command/run-workers.js';
|
|
17
|
-
import * as runMultiple from '../lib/command/run-multiple.js';
|
|
18
|
-
import { runRerun } from '../lib/command/run-rerun.js';
|
|
19
|
-
import * as dryRun from '../lib/command/dryRun.js';
|
|
20
|
-
import * as info from '../lib/command/info.js';
|
|
21
|
-
import { heal } from "../lib/command/generate.js";
|
|
22
|
-
|
|
23
|
-
const program = new Command();
|
|
2
|
+
const program = require('commander')
|
|
3
|
+
const Codecept = require('../lib/codecept')
|
|
4
|
+
const { print, error } = require('../lib/output')
|
|
5
|
+
const { printError } = require('../lib/command/utils')
|
|
24
6
|
|
|
25
7
|
const commandFlags = {
|
|
26
8
|
ai: {
|
|
@@ -47,104 +29,120 @@ const commandFlags = {
|
|
|
47
29
|
flag: '--steps',
|
|
48
30
|
description: 'show step-by-step execution',
|
|
49
31
|
},
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const errorHandler =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const errorHandler =
|
|
35
|
+
(fn) =>
|
|
36
|
+
async (...args) => {
|
|
37
|
+
try {
|
|
38
|
+
await fn(...args)
|
|
39
|
+
} catch (e) {
|
|
40
|
+
printError(e)
|
|
41
|
+
process.exitCode = 1
|
|
42
|
+
}
|
|
58
43
|
}
|
|
59
|
-
};
|
|
60
44
|
|
|
61
45
|
if (process.versions.node && process.versions.node.split('.') && process.versions.node.split('.')[0] < 12) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
process.exit(1)
|
|
46
|
+
error('NodeJS >= 12 is required to run.')
|
|
47
|
+
print()
|
|
48
|
+
print('Please upgrade your NodeJS engine')
|
|
49
|
+
print(`Current NodeJS version: ${process.version}`)
|
|
50
|
+
process.exit(1)
|
|
67
51
|
}
|
|
68
52
|
|
|
69
|
-
program.usage('<command> [options]')
|
|
70
|
-
program.version(version())
|
|
53
|
+
program.usage('<command> [options]')
|
|
54
|
+
program.version(Codecept.version())
|
|
71
55
|
|
|
72
|
-
program
|
|
56
|
+
program
|
|
57
|
+
.command('init [path]')
|
|
73
58
|
.description('Creates dummy config in current dir or [path]')
|
|
74
|
-
.action(errorHandler(init))
|
|
59
|
+
.action(errorHandler(require('../lib/command/init')))
|
|
75
60
|
|
|
76
|
-
program
|
|
61
|
+
program
|
|
62
|
+
.command('migrate [path]')
|
|
77
63
|
.description('Migrate json config to js config in current dir or [path]')
|
|
78
|
-
.action(errorHandler(configMigrate))
|
|
64
|
+
.action(errorHandler(require('../lib/command/configMigrate')))
|
|
79
65
|
|
|
80
|
-
program
|
|
66
|
+
program
|
|
67
|
+
.command('shell [path]')
|
|
81
68
|
.alias('sh')
|
|
82
69
|
.description('Interactive shell')
|
|
83
70
|
.option(commandFlags.verbose.flag, commandFlags.verbose.description)
|
|
84
71
|
.option(commandFlags.profile.flag, commandFlags.profile.description)
|
|
85
72
|
.option(commandFlags.ai.flag, commandFlags.ai.description)
|
|
86
73
|
.option(commandFlags.config.flag, commandFlags.config.description)
|
|
87
|
-
.action(errorHandler(interactive))
|
|
74
|
+
.action(errorHandler(require('../lib/command/interactive')))
|
|
88
75
|
|
|
89
|
-
program
|
|
76
|
+
program
|
|
77
|
+
.command('list [path]')
|
|
90
78
|
.alias('l')
|
|
91
79
|
.description('List all actions for I.')
|
|
92
|
-
.action(errorHandler(list))
|
|
80
|
+
.action(errorHandler(require('../lib/command/list')))
|
|
93
81
|
|
|
94
|
-
program
|
|
82
|
+
program
|
|
83
|
+
.command('def [path]')
|
|
95
84
|
.description('Generates TypeScript definitions for all I actions.')
|
|
96
85
|
.option(commandFlags.config.flag, commandFlags.config.description)
|
|
97
86
|
.option('-o, --output [folder]', 'target folder to paste definitions')
|
|
98
|
-
.action(errorHandler(definitions))
|
|
87
|
+
.action(errorHandler(require('../lib/command/definitions')))
|
|
99
88
|
|
|
100
|
-
program
|
|
89
|
+
program
|
|
90
|
+
.command('gherkin:init [path]')
|
|
101
91
|
.alias('bdd:init')
|
|
102
92
|
.description('Prepare CodeceptJS to run feature files.')
|
|
103
93
|
.option(commandFlags.config.flag, commandFlags.config.description)
|
|
104
|
-
.action(errorHandler(
|
|
94
|
+
.action(errorHandler(require('../lib/command/gherkin/init')))
|
|
105
95
|
|
|
106
|
-
program
|
|
96
|
+
program
|
|
97
|
+
.command('gherkin:steps [path]')
|
|
107
98
|
.alias('bdd:steps')
|
|
108
99
|
.description('Prints all defined gherkin steps.')
|
|
109
100
|
.option(commandFlags.config.flag, commandFlags.config.description)
|
|
110
|
-
.action(errorHandler(
|
|
101
|
+
.action(errorHandler(require('../lib/command/gherkin/steps')))
|
|
111
102
|
|
|
112
|
-
program
|
|
103
|
+
program
|
|
104
|
+
.command('gherkin:snippets [path]')
|
|
113
105
|
.alias('bdd:snippets')
|
|
114
106
|
.description('Generate step definitions from steps.')
|
|
115
107
|
.option('--dry-run', "don't save snippets to file")
|
|
116
108
|
.option(commandFlags.config.flag, commandFlags.config.description)
|
|
117
109
|
.option('--feature [file]', 'feature files(s) to scan')
|
|
118
110
|
.option('--path [file]', 'file in which to place the new snippets')
|
|
119
|
-
.action(errorHandler(
|
|
111
|
+
.action(errorHandler(require('../lib/command/gherkin/snippets')))
|
|
120
112
|
|
|
121
|
-
program
|
|
113
|
+
program
|
|
114
|
+
.command('generate:test [path]')
|
|
122
115
|
.alias('gt')
|
|
123
116
|
.description('Generates an empty test')
|
|
124
|
-
.action(errorHandler(generate.test))
|
|
117
|
+
.action(errorHandler(require('../lib/command/generate').test))
|
|
125
118
|
|
|
126
|
-
program
|
|
119
|
+
program
|
|
120
|
+
.command('generate:pageobject [path]')
|
|
127
121
|
.alias('gpo')
|
|
128
122
|
.description('Generates an empty page object')
|
|
129
|
-
.action(errorHandler(generate.pageObject))
|
|
123
|
+
.action(errorHandler(require('../lib/command/generate').pageObject))
|
|
130
124
|
|
|
131
|
-
program
|
|
125
|
+
program
|
|
126
|
+
.command('generate:object [path]')
|
|
132
127
|
.alias('go')
|
|
133
128
|
.option('--type, -t [kind]', 'type of object to be created')
|
|
134
129
|
.description('Generates an empty support object (page/step/fragment)')
|
|
135
|
-
.action(errorHandler(generate.pageObject))
|
|
130
|
+
.action(errorHandler(require('../lib/command/generate').pageObject))
|
|
136
131
|
|
|
137
|
-
program
|
|
132
|
+
program
|
|
133
|
+
.command('generate:helper [path]')
|
|
138
134
|
.alias('gh')
|
|
139
135
|
.description('Generates a new helper')
|
|
140
|
-
.action(errorHandler(generate.helper))
|
|
136
|
+
.action(errorHandler(require('../lib/command/generate').helper))
|
|
141
137
|
|
|
142
|
-
program
|
|
138
|
+
program
|
|
139
|
+
.command('generate:heal [path]')
|
|
143
140
|
.alias('gr')
|
|
144
141
|
.description('Generates basic heal recipes')
|
|
145
|
-
.action(errorHandler(heal))
|
|
142
|
+
.action(errorHandler(require('../lib/command/generate').heal))
|
|
146
143
|
|
|
147
|
-
program
|
|
144
|
+
program
|
|
145
|
+
.command('run [test]')
|
|
148
146
|
.description('Executes tests')
|
|
149
147
|
|
|
150
148
|
// codecept-only options
|
|
@@ -180,9 +178,10 @@ program.command('run [test]')
|
|
|
180
178
|
.option('--recursive', 'include sub directories')
|
|
181
179
|
.option('--trace', 'trace function calls')
|
|
182
180
|
.option('--child <string>', 'option for child processes')
|
|
183
|
-
.action(errorHandler(run))
|
|
181
|
+
.action(errorHandler(require('../lib/command/run')))
|
|
184
182
|
|
|
185
|
-
program
|
|
183
|
+
program
|
|
184
|
+
.command('run-workers <workers> [selectedRuns...]')
|
|
186
185
|
.description('Executes tests in workers')
|
|
187
186
|
.option(commandFlags.config.flag, commandFlags.config.description)
|
|
188
187
|
.option('-g, --grep <pattern>', 'only run tests matching <pattern>')
|
|
@@ -198,9 +197,10 @@ program.command('run-workers <workers> [selectedRuns...]')
|
|
|
198
197
|
.option('-p, --plugins <k=v,k2=v2,...>', 'enable plugins, comma-separated')
|
|
199
198
|
.option('-O, --reporter-options <k=v,k2=v2,...>', 'reporter-specific options')
|
|
200
199
|
.option('-R, --reporter <name>', 'specify the reporter to use')
|
|
201
|
-
.action(errorHandler(
|
|
200
|
+
.action(errorHandler(require('../lib/command/run-workers')))
|
|
202
201
|
|
|
203
|
-
program
|
|
202
|
+
program
|
|
203
|
+
.command('run-multiple [suites...]')
|
|
204
204
|
.description('Executes tests multiple')
|
|
205
205
|
.option(commandFlags.config.flag, commandFlags.config.description)
|
|
206
206
|
.option(commandFlags.profile.flag, commandFlags.profile.description)
|
|
@@ -223,14 +223,16 @@ program.command('run-multiple [suites...]')
|
|
|
223
223
|
// mocha options
|
|
224
224
|
.option('--colors', 'force enabling of colors')
|
|
225
225
|
|
|
226
|
-
.action(errorHandler(
|
|
226
|
+
.action(errorHandler(require('../lib/command/run-multiple')))
|
|
227
227
|
|
|
228
|
-
program
|
|
228
|
+
program
|
|
229
|
+
.command('info [path]')
|
|
229
230
|
.description('Print debugging information concerning the local environment')
|
|
230
231
|
.option('-c, --config', 'your config file path')
|
|
231
|
-
.action(errorHandler(info))
|
|
232
|
+
.action(errorHandler(require('../lib/command/info')))
|
|
232
233
|
|
|
233
|
-
program
|
|
234
|
+
program
|
|
235
|
+
.command('dry-run [test]')
|
|
234
236
|
.description('Prints step-by-step scenario for a test without actually running it')
|
|
235
237
|
.option('-p, --plugins <k=v,k2=v2,...>', 'enable plugins, comma-separated')
|
|
236
238
|
.option('--bootstrap', 'enable bootstrap & teardown scripts for dry-run')
|
|
@@ -244,9 +246,10 @@ program.command('dry-run [test]')
|
|
|
244
246
|
.option(commandFlags.steps.flag, commandFlags.steps.description)
|
|
245
247
|
.option(commandFlags.verbose.flag, commandFlags.verbose.description)
|
|
246
248
|
.option(commandFlags.debug.flag, commandFlags.debug.description)
|
|
247
|
-
.action(errorHandler(dryRun))
|
|
249
|
+
.action(errorHandler(require('../lib/command/dryRun')))
|
|
248
250
|
|
|
249
|
-
program
|
|
251
|
+
program
|
|
252
|
+
.command('run-rerun [test]')
|
|
250
253
|
.description('Executes tests in more than one test suite run')
|
|
251
254
|
|
|
252
255
|
// codecept-only options
|
|
@@ -281,15 +284,15 @@ program.command('run-rerun [test]')
|
|
|
281
284
|
.option('--trace', 'trace function calls')
|
|
282
285
|
.option('--child <string>', 'option for child processes')
|
|
283
286
|
|
|
284
|
-
.action(
|
|
287
|
+
.action(require('../lib/command/run-rerun'))
|
|
285
288
|
|
|
286
289
|
program.on('command:*', (cmd) => {
|
|
287
|
-
console.log(`\nUnknown command ${cmd}\n`)
|
|
288
|
-
program.outputHelp()
|
|
289
|
-
})
|
|
290
|
+
console.log(`\nUnknown command ${cmd}\n`)
|
|
291
|
+
program.outputHelp()
|
|
292
|
+
})
|
|
290
293
|
|
|
291
294
|
if (process.argv.length <= 2) {
|
|
292
|
-
program.outputHelp()
|
|
295
|
+
program.outputHelp()
|
|
293
296
|
} else {
|
|
294
|
-
program.parse(process.argv)
|
|
297
|
+
program.parse(process.argv)
|
|
295
298
|
}
|
package/lib/actor.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
const Step = require('./step');
|
|
2
|
+
const { MetaStep } = require('./step');
|
|
3
|
+
const container = require('./container');
|
|
4
|
+
const { methodsOfObject } = require('./utils');
|
|
5
|
+
const recorder = require('./recorder');
|
|
6
|
+
const event = require('./event');
|
|
7
|
+
const store = require('./store');
|
|
8
|
+
const output = require('./output');
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @interface
|
|
11
12
|
* @alias ActorStatic
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
class Actor {
|
|
14
15
|
/**
|
|
15
16
|
* Print the comment on log. Also, adding a step in the `Test.steps` object
|
|
16
17
|
* @param {string} msg
|
|
@@ -40,7 +41,7 @@ export class Actor {
|
|
|
40
41
|
if (!store.timeouts) return this;
|
|
41
42
|
|
|
42
43
|
event.dispatcher.prependOnceListener(event.step.before, (step) => {
|
|
43
|
-
output.
|
|
44
|
+
output.log(`Timeout to ${step}: ${timeout}s`);
|
|
44
45
|
step.setTimeout(timeout * 1000, Step.TIMEOUT_ORDER.codeLimitTime);
|
|
45
46
|
});
|
|
46
47
|
|
|
@@ -68,8 +69,7 @@ export class Actor {
|
|
|
68
69
|
* Wraps helper methods into promises.
|
|
69
70
|
* @ignore
|
|
70
71
|
*/
|
|
71
|
-
|
|
72
|
-
export function actor(obj = {}) {
|
|
72
|
+
module.exports = function (obj = {}) {
|
|
73
73
|
if (!store.actor) {
|
|
74
74
|
store.actor = new Actor();
|
|
75
75
|
}
|
|
@@ -117,9 +117,9 @@ export function actor(obj = {}) {
|
|
|
117
117
|
});
|
|
118
118
|
|
|
119
119
|
return actor;
|
|
120
|
-
}
|
|
120
|
+
};
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
function recordStep(step, args) {
|
|
123
123
|
step.status = 'queued';
|
|
124
124
|
step.setArguments(args);
|
|
125
125
|
|
package/lib/ai.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
debug('codeceptjs:ai');
|
|
1
|
+
const debug = require('debug')('codeceptjs:ai');
|
|
2
|
+
const output = require('./output');
|
|
3
|
+
const event = require('./event');
|
|
4
|
+
const { removeNonInteractiveElements, minifyHtml, splitByChunks } = require('./html');
|
|
7
5
|
|
|
8
6
|
const defaultHtmlConfig = {
|
|
9
7
|
maxLength: 50000,
|
|
@@ -124,8 +122,8 @@ class AiAssistant {
|
|
|
124
122
|
if (this.config.request) return;
|
|
125
123
|
|
|
126
124
|
const noRequestErrorMessage = `
|
|
127
|
-
No request function is set for AI assistant.
|
|
128
|
-
Please implement your own request function and set it in the config.
|
|
125
|
+
No request function is set for AI assistant.
|
|
126
|
+
Please implement your own request function and set it in the config.
|
|
129
127
|
|
|
130
128
|
[!] AI request was decoupled from CodeceptJS. To connect to OpenAI or other AI service, please implement your own request function and set it in the config.
|
|
131
129
|
|
|
@@ -189,11 +187,10 @@ class AiAssistant {
|
|
|
189
187
|
} catch (err) {
|
|
190
188
|
debug(err.response);
|
|
191
189
|
output.print('');
|
|
192
|
-
output.
|
|
193
|
-
if (err?.response?.data?.error?.code) output.
|
|
194
|
-
if (err?.response?.data?.error?.message) output.
|
|
190
|
+
output.error(`AI service error: ${err.message}`);
|
|
191
|
+
if (err?.response?.data?.error?.code) output.error(err?.response?.data?.error?.code);
|
|
192
|
+
if (err?.response?.data?.error?.message) output.error(err?.response?.data?.error?.message);
|
|
195
193
|
this.stopWhenReachingTokensLimit();
|
|
196
|
-
|
|
197
194
|
return '';
|
|
198
195
|
}
|
|
199
196
|
}
|
|
@@ -298,4 +295,4 @@ function parseCodeBlocks(response) {
|
|
|
298
295
|
return modifiedSnippets.filter(snippet => !!snippet);
|
|
299
296
|
}
|
|
300
297
|
|
|
301
|
-
|
|
298
|
+
module.exports = new AiAssistant();
|
package/lib/assert/empty.js
CHANGED
|
@@ -1,44 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const Assertion = require('../assert')
|
|
2
|
+
const AssertionFailedError = require('./error')
|
|
3
|
+
const { template } = require('../utils')
|
|
4
|
+
const output = require('../output')
|
|
5
5
|
|
|
6
6
|
class EmptinessAssertion extends Assertion {
|
|
7
7
|
constructor(params) {
|
|
8
8
|
super((value) => {
|
|
9
9
|
if (Array.isArray(value)) {
|
|
10
|
-
return value.length === 0
|
|
10
|
+
return value.length === 0
|
|
11
11
|
}
|
|
12
|
-
return !value
|
|
13
|
-
}, params)
|
|
14
|
-
this.params.type = 'to be empty'
|
|
12
|
+
return !value
|
|
13
|
+
}, params)
|
|
14
|
+
this.params.type = 'to be empty'
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
getException() {
|
|
18
18
|
if (Array.isArray(this.params.value)) {
|
|
19
|
-
this.params.value = `[${this.params.value.join(', ')}]
|
|
19
|
+
this.params.value = `[${this.params.value.join(', ')}]`
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const err = new AssertionFailedError(this.params, "{{customMessage}}expected {{subject}} '{{value}}' {{type}}")
|
|
22
|
+
const err = new AssertionFailedError(this.params, "{{customMessage}}expected {{subject}} '{{value}}' {{type}}")
|
|
23
23
|
|
|
24
24
|
err.cliMessage = () => {
|
|
25
25
|
const msg = err.template
|
|
26
26
|
.replace('{{value}}', output.colors.bold('{{value}}'))
|
|
27
|
-
.replace('{{subject}}', output.colors.bold('{{subject}}'))
|
|
28
|
-
return template(msg, this.params)
|
|
29
|
-
}
|
|
30
|
-
return err
|
|
27
|
+
.replace('{{subject}}', output.colors.bold('{{subject}}'))
|
|
28
|
+
return template(msg, this.params)
|
|
29
|
+
}
|
|
30
|
+
return err
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
addAssertParams() {
|
|
34
|
-
this.params.value = this.params.actual = arguments[0]
|
|
35
|
-
this.params.expected = []
|
|
36
|
-
this.params.customMessage = arguments[1] ? `${arguments[1]}\n\n` : ''
|
|
34
|
+
this.params.value = this.params.actual = arguments[0]
|
|
35
|
+
this.params.expected = []
|
|
36
|
+
this.params.customMessage = arguments[1] ? `${arguments[1]}\n\n` : ''
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return new EmptinessAssertion({ subject });
|
|
40
|
+
module.exports = {
|
|
41
|
+
Assertion: EmptinessAssertion,
|
|
42
|
+
empty: (subject) => new EmptinessAssertion({ subject }),
|
|
44
43
|
}
|
package/lib/assert/equal.js
CHANGED
|
@@ -1,59 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const Assertion = require('../assert')
|
|
2
|
+
const AssertionFailedError = require('./error')
|
|
3
|
+
const { template } = require('../utils')
|
|
4
|
+
const output = require('../output')
|
|
5
5
|
|
|
6
6
|
class EqualityAssertion extends Assertion {
|
|
7
7
|
constructor(params) {
|
|
8
8
|
const comparator = function (a, b) {
|
|
9
9
|
if (b.length === 0) {
|
|
10
|
-
b = ''
|
|
10
|
+
b = ''
|
|
11
11
|
}
|
|
12
|
-
return a === b
|
|
13
|
-
}
|
|
14
|
-
super(comparator, params)
|
|
15
|
-
this.params.type = 'to equal'
|
|
12
|
+
return a === b
|
|
13
|
+
}
|
|
14
|
+
super(comparator, params)
|
|
15
|
+
this.params.type = 'to equal'
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
getException() {
|
|
19
|
-
const params = this.params
|
|
20
|
-
params.jar = template(params.jar, params)
|
|
21
|
-
const err = new AssertionFailedError(
|
|
22
|
-
|
|
19
|
+
const params = this.params
|
|
20
|
+
params.jar = template(params.jar, params)
|
|
21
|
+
const err = new AssertionFailedError(
|
|
22
|
+
params,
|
|
23
|
+
'{{customMessage}}expected {{jar}} "{{expected}}" {{type}} "{{actual}}"',
|
|
24
|
+
)
|
|
25
|
+
err.showDiff = false
|
|
23
26
|
if (typeof err.cliMessage === 'function') {
|
|
24
|
-
err.message = err.cliMessage()
|
|
27
|
+
err.message = err.cliMessage()
|
|
25
28
|
}
|
|
26
29
|
err.cliMessage = () => {
|
|
27
|
-
const msg = err.template
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return err;
|
|
30
|
+
const msg = err.template.replace('{{jar}}', output.colors.bold('{{jar}}'))
|
|
31
|
+
return template(msg, this.params)
|
|
32
|
+
}
|
|
33
|
+
return err
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
addAssertParams() {
|
|
35
|
-
this.params.expected = arguments[0]
|
|
36
|
-
this.params.actual = arguments[1]
|
|
37
|
-
this.params.customMessage = arguments[2] ? `${arguments[2]}\n\n` : ''
|
|
37
|
+
this.params.expected = arguments[0]
|
|
38
|
+
this.params.actual = arguments[1]
|
|
39
|
+
this.params.customMessage = arguments[2] ? `${arguments[2]}\n\n` : ''
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const assert = new EqualityAssertion({ jar: 'url of current page' });
|
|
52
|
-
assert.comparator = function (expected, actual) {
|
|
53
|
-
if (expected.indexOf('http') !== 0) {
|
|
54
|
-
actual = actual.slice(actual.indexOf(baseUrl) + baseUrl.length);
|
|
43
|
+
module.exports = {
|
|
44
|
+
Assertion: EqualityAssertion,
|
|
45
|
+
equals: (jar) => new EqualityAssertion({ jar }),
|
|
46
|
+
urlEquals: (baseUrl) => {
|
|
47
|
+
const assert = new EqualityAssertion({ jar: 'url of current page' })
|
|
48
|
+
assert.comparator = function (expected, actual) {
|
|
49
|
+
if (expected.indexOf('http') !== 0) {
|
|
50
|
+
actual = actual.slice(actual.indexOf(baseUrl) + baseUrl.length)
|
|
51
|
+
}
|
|
52
|
+
return actual === expected
|
|
55
53
|
}
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
|
|
54
|
+
return assert
|
|
55
|
+
},
|
|
56
|
+
fileEquals: (file) => new EqualityAssertion({ file, jar: 'contents of {{file}}' }),
|
|
59
57
|
}
|
package/lib/assert/error.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const subs = require('../utils').template
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Assertion errors, can provide a detailed error messages.
|
|
@@ -6,27 +6,27 @@ import { template as subs } from '../utils.js';
|
|
|
6
6
|
* inspect() and cliMessage() added to display errors with params.
|
|
7
7
|
*/
|
|
8
8
|
function AssertionFailedError(params, template) {
|
|
9
|
-
this.params = params
|
|
10
|
-
this.template = template
|
|
9
|
+
this.params = params
|
|
10
|
+
this.template = template
|
|
11
11
|
// this.message = "AssertionFailedError";
|
|
12
12
|
// this.showDiff = true;
|
|
13
13
|
|
|
14
14
|
// @todo cut assert things nicer
|
|
15
|
-
this.showDiff = true
|
|
15
|
+
this.showDiff = true
|
|
16
16
|
|
|
17
|
-
this.actual = this.params.actual
|
|
18
|
-
this.expected = this.params.expected
|
|
17
|
+
this.actual = this.params.actual
|
|
18
|
+
this.expected = this.params.expected
|
|
19
19
|
|
|
20
20
|
this.inspect = () => {
|
|
21
|
-
const params = this.params || {}
|
|
22
|
-
const msg = params.customMessage || ''
|
|
23
|
-
return msg + subs(this.template, params)
|
|
24
|
-
}
|
|
21
|
+
const params = this.params || {}
|
|
22
|
+
const msg = params.customMessage || ''
|
|
23
|
+
return msg + subs(this.template, params)
|
|
24
|
+
}
|
|
25
25
|
|
|
26
|
-
this.cliMessage = () => this.inspect()
|
|
26
|
+
this.cliMessage = () => this.inspect()
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
AssertionFailedError.prototype = Object.create(Error.prototype)
|
|
30
|
-
AssertionFailedError.constructor = AssertionFailedError
|
|
29
|
+
AssertionFailedError.prototype = Object.create(Error.prototype)
|
|
30
|
+
AssertionFailedError.constructor = AssertionFailedError
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
module.exports = AssertionFailedError
|