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
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import('chai').then((chai) => {
|
|
6
|
-
expect = chai.expect
|
|
7
|
-
chai.use(require('chai-deep-match'))
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
const joi = require('joi')
|
|
1
|
+
import Helper from '@codeceptjs/helper'
|
|
2
|
+
import assert from 'assert'
|
|
3
|
+
import joi from 'joi'
|
|
11
4
|
|
|
12
5
|
/**
|
|
13
6
|
* This helper allows performing assertions on JSON responses paired with following helpers:
|
|
@@ -76,14 +69,17 @@ class JSONResponse extends Helper {
|
|
|
76
69
|
|
|
77
70
|
_beforeSuite() {
|
|
78
71
|
this.response = null
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
`Error setting JSONResponse, helper ${this.options.requestHelper} is not enabled in config, helpers: ${Object.keys(this.helpers)}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
72
|
+
try {
|
|
73
|
+
if (!this.helpers[this.options.requestHelper]) {
|
|
74
|
+
throw new Error(`Error setting JSONResponse, helper ${this.options.requestHelper} is not enabled in config, helpers: ${Object.keys(this.helpers)}`)
|
|
75
|
+
}
|
|
76
|
+
// connect to REST helper
|
|
77
|
+
this.helpers[this.options.requestHelper].config.onResponse = response => {
|
|
78
|
+
this.response = response
|
|
79
|
+
}
|
|
80
|
+
} catch (e) {
|
|
81
|
+
// Temporary workaround for ESM transition - helpers access issue
|
|
82
|
+
console.log('[JSONResponse] Warning: Could not connect to REST helper during ESM transition:', e.message)
|
|
87
83
|
}
|
|
88
84
|
}
|
|
89
85
|
|
|
@@ -93,7 +89,9 @@ class JSONResponse extends Helper {
|
|
|
93
89
|
|
|
94
90
|
static _checkRequirements() {
|
|
95
91
|
try {
|
|
96
|
-
|
|
92
|
+
// In ESM, joi is already imported at the top
|
|
93
|
+
// The import will fail at module load time if joi is missing
|
|
94
|
+
return null
|
|
97
95
|
} catch (e) {
|
|
98
96
|
return ['joi']
|
|
99
97
|
}
|
|
@@ -110,7 +108,7 @@ class JSONResponse extends Helper {
|
|
|
110
108
|
*/
|
|
111
109
|
seeResponseCodeIs(code) {
|
|
112
110
|
this._checkResponseReady()
|
|
113
|
-
|
|
111
|
+
assert.strictEqual(this.response.status, code, 'Response code is not the same as expected')
|
|
114
112
|
}
|
|
115
113
|
|
|
116
114
|
/**
|
|
@@ -124,7 +122,7 @@ class JSONResponse extends Helper {
|
|
|
124
122
|
*/
|
|
125
123
|
dontSeeResponseCodeIs(code) {
|
|
126
124
|
this._checkResponseReady()
|
|
127
|
-
|
|
125
|
+
assert.notStrictEqual(this.response.status, code)
|
|
128
126
|
}
|
|
129
127
|
|
|
130
128
|
/**
|
|
@@ -132,8 +130,7 @@ class JSONResponse extends Helper {
|
|
|
132
130
|
*/
|
|
133
131
|
seeResponseCodeIsClientError() {
|
|
134
132
|
this._checkResponseReady()
|
|
135
|
-
|
|
136
|
-
expect(this.response.status).to.be.lt(500)
|
|
133
|
+
assert(this.response.status >= 400 && this.response.status < 500)
|
|
137
134
|
}
|
|
138
135
|
|
|
139
136
|
/**
|
|
@@ -141,8 +138,7 @@ class JSONResponse extends Helper {
|
|
|
141
138
|
*/
|
|
142
139
|
seeResponseCodeIsRedirection() {
|
|
143
140
|
this._checkResponseReady()
|
|
144
|
-
|
|
145
|
-
expect(this.response.status).to.be.lt(400)
|
|
141
|
+
assert(this.response.status >= 300 && this.response.status < 400)
|
|
146
142
|
}
|
|
147
143
|
|
|
148
144
|
/**
|
|
@@ -150,8 +146,7 @@ class JSONResponse extends Helper {
|
|
|
150
146
|
*/
|
|
151
147
|
seeResponseCodeIsServerError() {
|
|
152
148
|
this._checkResponseReady()
|
|
153
|
-
|
|
154
|
-
expect(this.response.status).to.be.lt(600)
|
|
149
|
+
assert(this.response.status >= 500 && this.response.status < 600)
|
|
155
150
|
}
|
|
156
151
|
|
|
157
152
|
/**
|
|
@@ -164,8 +159,7 @@ class JSONResponse extends Helper {
|
|
|
164
159
|
*/
|
|
165
160
|
seeResponseCodeIsSuccessful() {
|
|
166
161
|
this._checkResponseReady()
|
|
167
|
-
|
|
168
|
-
expect(this.response.status).to.be.lt(300)
|
|
162
|
+
assert(this.response.status >= 200 && this.response.status < 300)
|
|
169
163
|
}
|
|
170
164
|
|
|
171
165
|
/**
|
|
@@ -188,17 +182,19 @@ class JSONResponse extends Helper {
|
|
|
188
182
|
seeResponseContainsJson(json = {}) {
|
|
189
183
|
this._checkResponseReady()
|
|
190
184
|
if (Array.isArray(this.response.data)) {
|
|
191
|
-
let
|
|
185
|
+
let found = false
|
|
192
186
|
for (const el of this.response.data) {
|
|
193
187
|
try {
|
|
194
|
-
|
|
188
|
+
this._assertContains(el, json)
|
|
189
|
+
found = true
|
|
190
|
+
break
|
|
195
191
|
} catch (err) {
|
|
196
|
-
|
|
192
|
+
continue
|
|
197
193
|
}
|
|
198
194
|
}
|
|
199
|
-
|
|
195
|
+
assert(found, `No elements in array matched ${JSON.stringify(json)}`)
|
|
200
196
|
} else {
|
|
201
|
-
|
|
197
|
+
this._assertContains(this.response.data, json)
|
|
202
198
|
}
|
|
203
199
|
}
|
|
204
200
|
|
|
@@ -222,9 +218,22 @@ class JSONResponse extends Helper {
|
|
|
222
218
|
dontSeeResponseContainsJson(json = {}) {
|
|
223
219
|
this._checkResponseReady()
|
|
224
220
|
if (Array.isArray(this.response.data)) {
|
|
225
|
-
this.response.data
|
|
221
|
+
for (const data of this.response.data) {
|
|
222
|
+
try {
|
|
223
|
+
this._assertContains(data, json)
|
|
224
|
+
assert.fail(`Found matching element: ${JSON.stringify(data)}`)
|
|
225
|
+
} catch (err) {
|
|
226
|
+
// expected to fail
|
|
227
|
+
continue
|
|
228
|
+
}
|
|
229
|
+
}
|
|
226
230
|
} else {
|
|
227
|
-
|
|
231
|
+
try {
|
|
232
|
+
this._assertContains(this.response.data, json)
|
|
233
|
+
assert.fail('Response contains the JSON')
|
|
234
|
+
} catch (err) {
|
|
235
|
+
// expected to fail
|
|
236
|
+
}
|
|
228
237
|
}
|
|
229
238
|
}
|
|
230
239
|
|
|
@@ -250,20 +259,27 @@ class JSONResponse extends Helper {
|
|
|
250
259
|
seeResponseContainsKeys(keys = []) {
|
|
251
260
|
this._checkResponseReady()
|
|
252
261
|
if (Array.isArray(this.response.data)) {
|
|
253
|
-
this.response.data
|
|
262
|
+
for (const data of this.response.data) {
|
|
263
|
+
for (const key of keys) {
|
|
264
|
+
assert(key in data, `Key "${key}" is not found in ${JSON.stringify(data)}`)
|
|
265
|
+
}
|
|
266
|
+
}
|
|
254
267
|
} else {
|
|
255
|
-
|
|
268
|
+
for (const key of keys) {
|
|
269
|
+
assert(key in this.response.data, `Key "${key}" is not found in ${JSON.stringify(this.response.data)}`)
|
|
270
|
+
}
|
|
256
271
|
}
|
|
257
272
|
}
|
|
258
273
|
|
|
259
274
|
/**
|
|
260
|
-
* Executes a callback function passing in `response` object and
|
|
275
|
+
* Executes a callback function passing in `response` object and assert
|
|
261
276
|
* Use it to perform custom checks of response data
|
|
262
277
|
*
|
|
263
278
|
* ```js
|
|
264
|
-
* I.seeResponseValidByCallback(({ data, status
|
|
265
|
-
*
|
|
266
|
-
*
|
|
279
|
+
* I.seeResponseValidByCallback(({ data, status }) => {
|
|
280
|
+
* assert.strictEqual(status, 200);
|
|
281
|
+
* assert('user' in data);
|
|
282
|
+
* assert('company' in data);
|
|
267
283
|
* });
|
|
268
284
|
* ```
|
|
269
285
|
*
|
|
@@ -271,7 +287,7 @@ class JSONResponse extends Helper {
|
|
|
271
287
|
*/
|
|
272
288
|
seeResponseValidByCallback(fn) {
|
|
273
289
|
this._checkResponseReady()
|
|
274
|
-
fn({ ...this.response,
|
|
290
|
+
fn({ ...this.response, assert })
|
|
275
291
|
const body = fn.toString()
|
|
276
292
|
fn.toString = () => `${body.split('\n')[1]}...`
|
|
277
293
|
}
|
|
@@ -288,7 +304,7 @@ class JSONResponse extends Helper {
|
|
|
288
304
|
*/
|
|
289
305
|
seeResponseEquals(resp) {
|
|
290
306
|
this._checkResponseReady()
|
|
291
|
-
|
|
307
|
+
assert.deepStrictEqual(this.response.data, resp)
|
|
292
308
|
}
|
|
293
309
|
|
|
294
310
|
/**
|
|
@@ -335,6 +351,17 @@ class JSONResponse extends Helper {
|
|
|
335
351
|
_checkResponseReady() {
|
|
336
352
|
if (!this.response) throw new Error('Response is not available')
|
|
337
353
|
}
|
|
354
|
+
|
|
355
|
+
_assertContains(actual, expected) {
|
|
356
|
+
for (const key in expected) {
|
|
357
|
+
assert(key in actual, `Key "${key}" not found in ${JSON.stringify(actual)}`)
|
|
358
|
+
if (typeof expected[key] === 'object' && expected[key] !== null) {
|
|
359
|
+
this._assertContains(actual[key], expected[key])
|
|
360
|
+
} else {
|
|
361
|
+
assert.deepStrictEqual(actual[key], expected[key], `Values for key "${key}" don't match`)
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
338
365
|
}
|
|
339
366
|
|
|
340
|
-
|
|
367
|
+
export { JSONResponse as default }
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
let addMochawesomeContext
|
|
2
1
|
let currentTest
|
|
3
2
|
let currentSuite
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import Helper from '@codeceptjs/helper'
|
|
5
|
+
import { createRequire } from 'module'
|
|
6
|
+
import { clearString } from '../utils.js'
|
|
7
|
+
import { testToFileName } from '../mocha/test.js'
|
|
7
8
|
|
|
8
9
|
class Mochawesome extends Helper {
|
|
9
10
|
constructor(config) {
|
|
@@ -15,7 +16,10 @@ class Mochawesome extends Helper {
|
|
|
15
16
|
disableScreenshots: false,
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
// ESM-compatible require for CommonJS module
|
|
20
|
+
const require = createRequire(import.meta.url)
|
|
21
|
+
this._addContext = require('mochawesome/addContext')
|
|
22
|
+
|
|
19
23
|
this._createConfig(config)
|
|
20
24
|
}
|
|
21
25
|
|
|
@@ -43,29 +47,28 @@ class Mochawesome extends Helper {
|
|
|
43
47
|
if (this.options.disableScreenshots) return
|
|
44
48
|
let fileName
|
|
45
49
|
// Get proper name if we are fail on hook
|
|
46
|
-
if (test.ctx
|
|
50
|
+
if (test.ctx?.test?.type === 'hook') {
|
|
47
51
|
currentTest = { test: test.ctx.test }
|
|
48
52
|
// ignore retries if we are in hook
|
|
49
53
|
test._retries = -1
|
|
50
54
|
fileName = clearString(`${test.title}_${currentTest.test.title}`)
|
|
51
55
|
} else {
|
|
52
56
|
currentTest = { test }
|
|
53
|
-
fileName =
|
|
57
|
+
fileName = testToFileName(test)
|
|
54
58
|
}
|
|
55
59
|
if (this.options.uniqueScreenshotNames) {
|
|
56
|
-
|
|
57
|
-
fileName = `${fileName.substring(0, 10)}_${uuid}`
|
|
60
|
+
fileName = testToFileName(test, { unique: true })
|
|
58
61
|
}
|
|
59
62
|
if (test._retries < 1 || test._retries === test.retryNum) {
|
|
60
63
|
fileName = `${fileName}.failed.png`
|
|
61
|
-
return
|
|
64
|
+
return this._addContext(currentTest, fileName)
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
addMochawesomeContext(context) {
|
|
66
69
|
if (currentTest === '') currentTest = { test: currentSuite.ctx.test }
|
|
67
|
-
return
|
|
70
|
+
return this._addContext(currentTest, context)
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
73
|
|
|
71
|
-
|
|
74
|
+
export default Mochawesome
|