codeceptjs 4.0.0-beta.1 → 4.0.0-beta.11.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 +133 -120
- package/bin/codecept.js +107 -96
- package/bin/test-server.js +64 -0
- package/docs/webapi/clearCookie.mustache +1 -1
- package/docs/webapi/click.mustache +5 -1
- package/lib/actor.js +71 -103
- package/lib/ai.js +159 -188
- package/lib/assert/empty.js +22 -24
- package/lib/assert/equal.js +30 -37
- package/lib/assert/error.js +14 -14
- package/lib/assert/include.js +43 -48
- package/lib/assert/throws.js +11 -11
- package/lib/assert/truth.js +22 -22
- package/lib/assert.js +20 -18
- package/lib/codecept.js +238 -162
- package/lib/colorUtils.js +50 -52
- package/lib/command/check.js +206 -0
- package/lib/command/configMigrate.js +56 -51
- package/lib/command/definitions.js +96 -109
- package/lib/command/dryRun.js +77 -79
- package/lib/command/generate.js +234 -194
- package/lib/command/gherkin/init.js +42 -33
- package/lib/command/gherkin/snippets.js +76 -74
- package/lib/command/gherkin/steps.js +20 -17
- package/lib/command/info.js +74 -38
- package/lib/command/init.js +300 -290
- package/lib/command/interactive.js +41 -32
- package/lib/command/list.js +28 -27
- package/lib/command/run-multiple/chunk.js +51 -48
- package/lib/command/run-multiple/collection.js +5 -5
- package/lib/command/run-multiple/run.js +5 -1
- package/lib/command/run-multiple.js +97 -97
- package/lib/command/run-rerun.js +19 -25
- package/lib/command/run-workers.js +68 -92
- package/lib/command/run.js +39 -27
- package/lib/command/utils.js +80 -64
- package/lib/command/workers/runTests.js +388 -226
- package/lib/config.js +124 -50
- package/lib/container.js +765 -260
- package/lib/data/context.js +60 -61
- package/lib/data/dataScenarioConfig.js +47 -47
- package/lib/data/dataTableArgument.js +32 -32
- package/lib/data/table.js +22 -22
- package/lib/effects.js +307 -0
- package/lib/element/WebElement.js +327 -0
- package/lib/els.js +160 -0
- package/lib/event.js +173 -163
- package/lib/globals.js +141 -0
- package/lib/heal.js +89 -85
- package/lib/helper/AI.js +131 -41
- package/lib/helper/ApiDataFactory.js +107 -75
- package/lib/helper/Appium.js +542 -404
- package/lib/helper/FileSystem.js +100 -79
- package/lib/helper/GraphQL.js +44 -43
- package/lib/helper/GraphQLDataFactory.js +52 -52
- package/lib/helper/JSONResponse.js +126 -88
- package/lib/helper/Mochawesome.js +54 -29
- package/lib/helper/Playwright.js +2547 -1316
- package/lib/helper/Puppeteer.js +1578 -1181
- package/lib/helper/REST.js +209 -68
- package/lib/helper/WebDriver.js +1482 -1342
- 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/PlaywrightReactVueLocator.js +17 -8
- package/lib/helper/extras/PlaywrightRestartOpts.js +25 -11
- package/lib/helper/extras/Popup.js +22 -22
- package/lib/helper/extras/React.js +27 -28
- package/lib/helper/network/actions.js +36 -42
- package/lib/helper/network/utils.js +78 -84
- package/lib/helper/scripts/blurElement.js +5 -5
- package/lib/helper/scripts/focusElement.js +5 -5
- package/lib/helper/scripts/highlightElement.js +8 -8
- package/lib/helper/scripts/isElementClickable.js +34 -34
- package/lib/helper.js +2 -3
- package/lib/history.js +23 -19
- package/lib/hooks.js +8 -8
- package/lib/html.js +94 -104
- package/lib/index.js +38 -27
- package/lib/listener/config.js +30 -23
- package/lib/listener/emptyRun.js +54 -0
- package/lib/listener/enhancedGlobalRetry.js +110 -0
- package/lib/listener/exit.js +16 -18
- package/lib/listener/globalRetry.js +70 -0
- package/lib/listener/globalTimeout.js +181 -0
- package/lib/listener/helpers.js +76 -51
- package/lib/listener/mocha.js +10 -11
- package/lib/listener/result.js +11 -0
- package/lib/listener/retryEnhancer.js +85 -0
- package/lib/listener/steps.js +71 -59
- package/lib/listener/store.js +20 -0
- package/lib/locator.js +214 -197
- package/lib/mocha/asyncWrapper.js +274 -0
- package/lib/mocha/bdd.js +167 -0
- package/lib/mocha/cli.js +341 -0
- package/lib/mocha/factory.js +163 -0
- package/lib/mocha/featureConfig.js +89 -0
- package/lib/mocha/gherkin.js +231 -0
- 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 +58 -34
- package/lib/mocha/suite.js +89 -0
- package/lib/mocha/test.js +184 -0
- package/lib/mocha/types.d.ts +42 -0
- package/lib/mocha/ui.js +242 -0
- package/lib/output.js +141 -71
- package/lib/parser.js +47 -44
- package/lib/pause.js +173 -145
- package/lib/plugin/analyze.js +403 -0
- package/lib/plugin/{autoLogin.js → auth.js} +178 -79
- package/lib/plugin/autoDelay.js +36 -40
- package/lib/plugin/coverage.js +131 -78
- package/lib/plugin/customLocator.js +22 -21
- package/lib/plugin/customReporter.js +53 -0
- package/lib/plugin/enhancedRetryFailedStep.js +99 -0
- package/lib/plugin/heal.js +101 -110
- package/lib/plugin/htmlReporter.js +3648 -0
- package/lib/plugin/pageInfo.js +140 -0
- package/lib/plugin/pauseOnFail.js +12 -11
- package/lib/plugin/retryFailedStep.js +82 -47
- package/lib/plugin/screenshotOnFail.js +111 -92
- package/lib/plugin/stepByStepReport.js +159 -101
- package/lib/plugin/stepTimeout.js +20 -25
- package/lib/plugin/subtitles.js +38 -38
- package/lib/recorder.js +193 -130
- package/lib/rerun.js +94 -49
- package/lib/result.js +238 -0
- package/lib/retryCoordinator.js +207 -0
- package/lib/secret.js +20 -18
- 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 -329
- package/lib/steps.js +54 -0
- package/lib/store.js +38 -7
- package/lib/template/heal.js +3 -12
- package/lib/template/prompts/generatePageObject.js +31 -0
- package/lib/template/prompts/healStep.js +13 -0
- package/lib/template/prompts/writeStep.js +9 -0
- package/lib/test-server.js +334 -0
- package/lib/timeout.js +60 -0
- package/lib/transform.js +8 -8
- package/lib/translation.js +34 -21
- package/lib/utils/mask_data.js +47 -0
- package/lib/utils.js +411 -228
- package/lib/workerStorage.js +37 -34
- package/lib/workers.js +532 -296
- package/package.json +115 -95
- package/translations/de-DE.js +5 -3
- package/translations/fr-FR.js +5 -4
- package/translations/index.js +22 -12
- package/translations/it-IT.js +4 -3
- package/translations/ja-JP.js +4 -3
- package/translations/nl-NL.js +76 -0
- package/translations/pl-PL.js +4 -3
- package/translations/pt-BR.js +4 -3
- package/translations/ru-RU.js +4 -3
- package/translations/utils.js +10 -0
- package/translations/zh-CN.js +4 -3
- package/translations/zh-TW.js +4 -3
- package/typings/index.d.ts +546 -185
- package/typings/promiseBasedTypes.d.ts +150 -879
- package/typings/types.d.ts +547 -996
- package/lib/cli.js +0 -249
- package/lib/dirname.js +0 -5
- package/lib/helper/Expect.js +0 -425
- package/lib/helper/ExpectHelper.js +0 -399
- package/lib/helper/MockServer.js +0 -223
- package/lib/helper/Nightmare.js +0 -1411
- package/lib/helper/Protractor.js +0 -1835
- package/lib/helper/SoftExpectHelper.js +0 -381
- package/lib/helper/TestCafe.js +0 -1410
- package/lib/helper/clientscripts/nightmare.js +0 -213
- package/lib/helper/testcafe/testControllerHolder.js +0 -42
- package/lib/helper/testcafe/testcafe-utils.js +0 -63
- package/lib/interfaces/bdd.js +0 -98
- package/lib/interfaces/featureConfig.js +0 -69
- package/lib/interfaces/gherkin.js +0 -195
- package/lib/listener/artifacts.js +0 -19
- package/lib/listener/retry.js +0 -68
- package/lib/listener/timeout.js +0 -109
- package/lib/mochaFactory.js +0 -110
- 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 -121
- package/lib/plugin/selenoid.js +0 -371
- package/lib/plugin/standardActingHelpers.js +0 -9
- package/lib/plugin/tryTo.js +0 -105
- package/lib/plugin/wdio.js +0 -246
- package/lib/scenario.js +0 -222
- package/lib/ui.js +0 -238
- package/lib/within.js +0 -70
package/lib/config.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import fs from 'fs'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
fileExists, isFile, deepMerge, deepClone,
|
|
6
|
-
} from './utils.js';
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import { createRequire } from 'module'
|
|
4
|
+
import { fileExists, isFile, deepMerge, deepClone } from './utils.js'
|
|
7
5
|
|
|
8
6
|
const defaultConfig = {
|
|
9
7
|
output: './_output',
|
|
@@ -31,18 +29,12 @@ const defaultConfig = {
|
|
|
31
29
|
timeout: 0,
|
|
32
30
|
},
|
|
33
31
|
],
|
|
34
|
-
}
|
|
32
|
+
}
|
|
35
33
|
|
|
36
|
-
let hooks = []
|
|
37
|
-
let config = {}
|
|
34
|
+
let hooks = []
|
|
35
|
+
let config = {}
|
|
38
36
|
|
|
39
|
-
const configFileNames = [
|
|
40
|
-
'codecept.config.js',
|
|
41
|
-
'codecept.conf.js',
|
|
42
|
-
'codecept.js',
|
|
43
|
-
'codecept.config.ts',
|
|
44
|
-
'codecept.conf.ts',
|
|
45
|
-
];
|
|
37
|
+
const configFileNames = ['codecept.config.js', 'codecept.conf.js', 'codecept.js', 'codecept.config.cjs', 'codecept.conf.cjs', 'codecept.config.ts', 'codecept.conf.ts']
|
|
46
38
|
|
|
47
39
|
/**
|
|
48
40
|
* Current configuration
|
|
@@ -55,9 +47,9 @@ class Config {
|
|
|
55
47
|
* @return {Object<string, *>}
|
|
56
48
|
*/
|
|
57
49
|
static create(newConfig) {
|
|
58
|
-
config = deepMerge(deepClone(defaultConfig), newConfig)
|
|
59
|
-
hooks.forEach(f => f(config))
|
|
60
|
-
return config
|
|
50
|
+
config = deepMerge(deepClone(defaultConfig), newConfig)
|
|
51
|
+
hooks.forEach(f => f(config))
|
|
52
|
+
return config
|
|
61
53
|
}
|
|
62
54
|
|
|
63
55
|
/**
|
|
@@ -73,34 +65,45 @@ class Config {
|
|
|
73
65
|
* @param {string} configFile
|
|
74
66
|
* @return {*}
|
|
75
67
|
*/
|
|
76
|
-
static load(configFile) {
|
|
77
|
-
configFile = path.resolve(configFile || '.')
|
|
68
|
+
static async load(configFile) {
|
|
69
|
+
configFile = path.resolve(configFile || '.')
|
|
78
70
|
|
|
79
71
|
if (!fileExists(configFile)) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
72
|
+
// Try different extensions if the file doesn't exist
|
|
73
|
+
const extensions = ['.ts', '.cjs', '.mjs']
|
|
74
|
+
let found = false
|
|
75
|
+
|
|
76
|
+
for (const ext of extensions) {
|
|
77
|
+
const altConfig = configFile.replace(/\.js$/, ext)
|
|
78
|
+
if (fileExists(altConfig)) {
|
|
79
|
+
configFile = altConfig
|
|
80
|
+
found = true
|
|
81
|
+
break
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (!found) {
|
|
86
|
+
throw new Error(`Config file ${configFile} does not exist. Execute 'codeceptjs init' to create config`)
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
// is config file
|
|
88
91
|
if (isFile(configFile)) {
|
|
89
|
-
return loadConfigFile(configFile)
|
|
92
|
+
return await loadConfigFile(configFile)
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
for (const name of configFileNames) {
|
|
93
96
|
// is path to directory
|
|
94
|
-
const jsConfig = path.join(configFile, name)
|
|
97
|
+
const jsConfig = path.join(configFile, name)
|
|
95
98
|
|
|
96
99
|
if (isFile(jsConfig)) {
|
|
97
|
-
return loadConfigFile(jsConfig)
|
|
100
|
+
return await loadConfigFile(jsConfig)
|
|
98
101
|
}
|
|
99
102
|
}
|
|
100
103
|
|
|
101
|
-
const configPaths = configFileNames.map(name => path.join(configFile, name)).join(' or ')
|
|
104
|
+
const configPaths = configFileNames.map(name => path.join(configFile, name)).join(' or ')
|
|
102
105
|
|
|
103
|
-
throw new Error(`Can not load config from ${configPaths}\nCodeceptJS is not initialized in this dir. Execute 'codeceptjs init' to start`)
|
|
106
|
+
throw new Error(`Can not load config from ${configPaths}\nCodeceptJS is not initialized in this dir. Execute 'codeceptjs init' to start`)
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
/**
|
|
@@ -111,13 +114,13 @@ class Config {
|
|
|
111
114
|
*/
|
|
112
115
|
static get(key, val) {
|
|
113
116
|
if (key) {
|
|
114
|
-
return config[key] || val
|
|
117
|
+
return config[key] || val
|
|
115
118
|
}
|
|
116
|
-
return config
|
|
119
|
+
return config
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
static addHook(fn) {
|
|
120
|
-
hooks.push(fn)
|
|
123
|
+
hooks.push(fn)
|
|
121
124
|
}
|
|
122
125
|
|
|
123
126
|
/**
|
|
@@ -127,7 +130,7 @@ class Config {
|
|
|
127
130
|
* @return {Object<string, *>}
|
|
128
131
|
*/
|
|
129
132
|
static append(additionalConfig) {
|
|
130
|
-
return config = deepMerge(config, additionalConfig)
|
|
133
|
+
return (config = deepMerge(config, additionalConfig))
|
|
131
134
|
}
|
|
132
135
|
|
|
133
136
|
/**
|
|
@@ -135,34 +138,105 @@ class Config {
|
|
|
135
138
|
* @return {Object<string, *>}
|
|
136
139
|
*/
|
|
137
140
|
static reset() {
|
|
138
|
-
hooks = []
|
|
139
|
-
return config = { ...defaultConfig }
|
|
141
|
+
hooks = []
|
|
142
|
+
return (config = { ...defaultConfig })
|
|
140
143
|
}
|
|
141
144
|
}
|
|
142
145
|
|
|
143
|
-
export default Config
|
|
146
|
+
export default Config
|
|
144
147
|
|
|
145
|
-
function loadConfigFile(configFile) {
|
|
146
|
-
const
|
|
148
|
+
async function loadConfigFile(configFile) {
|
|
149
|
+
const require = createRequire(import.meta.url)
|
|
150
|
+
const extensionName = path.extname(configFile)
|
|
147
151
|
|
|
148
|
-
|
|
152
|
+
// .conf.js config file
|
|
153
|
+
if (extensionName === '.js' || extensionName === '.ts' || extensionName === '.cjs') {
|
|
154
|
+
let configModule
|
|
149
155
|
try {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
156
|
+
// For .ts files, try to compile and load as JavaScript
|
|
157
|
+
if (extensionName === '.ts') {
|
|
158
|
+
try {
|
|
159
|
+
// Try to load ts-node and compile the file
|
|
160
|
+
const { transpile } = require('typescript')
|
|
161
|
+
const tsContent = fs.readFileSync(configFile, 'utf8')
|
|
162
|
+
|
|
163
|
+
// Transpile TypeScript to JavaScript with ES module output
|
|
164
|
+
const jsContent = transpile(tsContent, {
|
|
165
|
+
module: 99, // ModuleKind.ESNext
|
|
166
|
+
target: 99, // ScriptTarget.ESNext
|
|
167
|
+
esModuleInterop: true,
|
|
168
|
+
allowSyntheticDefaultImports: true,
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
// Create a temporary JS file with .mjs extension to force ES module treatment
|
|
172
|
+
const tempJsFile = configFile.replace('.ts', '.temp.mjs')
|
|
173
|
+
fs.writeFileSync(tempJsFile, jsContent)
|
|
174
|
+
|
|
175
|
+
try {
|
|
176
|
+
configModule = await import(tempJsFile)
|
|
177
|
+
// Clean up temp file
|
|
178
|
+
fs.unlinkSync(tempJsFile)
|
|
179
|
+
} catch (err) {
|
|
180
|
+
// Clean up temp file even on error
|
|
181
|
+
if (fs.existsSync(tempJsFile)) {
|
|
182
|
+
fs.unlinkSync(tempJsFile)
|
|
183
|
+
}
|
|
184
|
+
throw err
|
|
185
|
+
}
|
|
186
|
+
} catch (tsError) {
|
|
187
|
+
// If TypeScript compilation fails, fallback to ts-node
|
|
188
|
+
try {
|
|
189
|
+
require('ts-node/register')
|
|
190
|
+
configModule = require(configFile)
|
|
191
|
+
} catch (tsNodeError) {
|
|
192
|
+
throw new Error(`Failed to load TypeScript config: ${tsError.message}`)
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
// Try ESM import first for JS files
|
|
197
|
+
configModule = await import(configFile)
|
|
198
|
+
}
|
|
199
|
+
} catch (importError) {
|
|
200
|
+
try {
|
|
201
|
+
// Fall back to CommonJS require for .js/.cjs files
|
|
202
|
+
if (extensionName !== '.ts') {
|
|
203
|
+
configModule = require(configFile)
|
|
204
|
+
} else {
|
|
205
|
+
throw importError
|
|
206
|
+
}
|
|
207
|
+
} catch (requireError) {
|
|
208
|
+
throw new Error(`Failed to load config file ${configFile}: ${importError.message}`)
|
|
209
|
+
}
|
|
153
210
|
}
|
|
154
|
-
}
|
|
155
211
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
212
|
+
const rawConfig = configModule.config || configModule.default?.config || configModule.default || configModule
|
|
213
|
+
|
|
214
|
+
// Process helpers to extract imported classes
|
|
215
|
+
if (rawConfig.helpers) {
|
|
216
|
+
const processedHelpers = {}
|
|
217
|
+
for (const [helperName, helperConfig] of Object.entries(rawConfig.helpers)) {
|
|
218
|
+
// Check if the helper name itself is a class (ESM import)
|
|
219
|
+
if (typeof helperName === 'function' && helperName.prototype) {
|
|
220
|
+
// This is an imported class, use its constructor name
|
|
221
|
+
const className = helperName.name
|
|
222
|
+
processedHelpers[className] = {
|
|
223
|
+
...helperConfig,
|
|
224
|
+
_helperClass: helperName,
|
|
225
|
+
}
|
|
226
|
+
} else {
|
|
227
|
+
processedHelpers[helperName] = helperConfig
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
rawConfig.helpers = processedHelpers
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return Config.create(rawConfig)
|
|
160
234
|
}
|
|
161
235
|
|
|
162
236
|
// json config provided
|
|
163
237
|
if (extensionName === '.json') {
|
|
164
|
-
return Config.create(JSON.parse(fs.readFileSync(configFile, 'utf8')))
|
|
238
|
+
return Config.create(JSON.parse(fs.readFileSync(configFile, 'utf8')))
|
|
165
239
|
}
|
|
166
240
|
|
|
167
|
-
throw new Error(`Config file ${configFile} can't be loaded`)
|
|
241
|
+
throw new Error(`Config file ${configFile} can't be loaded`)
|
|
168
242
|
}
|