codeceptjs 4.2.0 → 4.2.1-beta.1
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 -0
- package/bin/codecept.js +11 -0
- package/docs/agents.md +26 -1
- package/docs/ai.md +57 -0
- package/docs/alternative-browsers.md +175 -148
- package/docs/assertions.md +74 -0
- package/docs/bootstrap.md +2 -0
- package/docs/commands.md +45 -0
- package/docs/configuration.md +37 -0
- package/docs/debugging.md +1 -1
- package/docs/helpers/ApiDataFactory.md +20 -20
- package/docs/helpers/Appium.md +1615 -670
- package/docs/helpers/Decision.md +146 -0
- package/docs/helpers/GraphQL.md +31 -31
- package/docs/helpers/GraphQLDataFactory.md +20 -20
- package/docs/helpers/Kitesurf.md +1808 -25
- package/docs/helpers/Lightpanda.md +139 -0
- package/docs/helpers/Obscura.md +1799 -74
- package/docs/helpers/Playwright.md +490 -428
- package/docs/helpers/Puppeteer.md +317 -255
- package/docs/helpers/REST.md +43 -43
- package/docs/helpers/WebDriver.md +237 -175
- package/docs/installation.md +16 -0
- package/docs/mcp.md +7 -1
- package/docs/parallel.md +35 -1
- package/docs/plugins/pause.md +2 -1
- package/docs/plugins/sitemap.md +48 -0
- package/docs/plugins.md +4 -0
- package/lib/ai.js +81 -2
- package/lib/codecept.js +32 -2
- package/lib/command/init.js +22 -0
- package/lib/command/initAgent.js +78 -0
- package/lib/command/run-multiple.js +3 -0
- package/lib/command/run-workers.js +10 -3
- package/lib/command/run.js +3 -2
- package/lib/command/utils.js +15 -0
- package/lib/command/workers/runTests.js +10 -10
- package/lib/container.js +4 -2
- package/lib/effects.js +19 -1
- package/lib/helper/CDPBrowser.js +349 -1384
- package/lib/helper/Decision.js +256 -0
- package/lib/helper/Kitesurf.js +3 -21
- package/lib/helper/Lightpanda.js +137 -0
- package/lib/helper/Obscura.js +21 -238
- package/lib/helper/Playwright.js +6 -4
- package/lib/helper/Puppeteer.js +12 -7
- package/lib/helper/WebDriver.js +2 -1
- package/lib/listener/result.js +4 -0
- package/lib/mocha/bdd.js +19 -1
- package/lib/plugin/junitReporter.js +4 -1
- package/lib/plugin/pause.js +4 -1
- package/lib/plugin/sitemap.js +228 -0
- package/lib/recorder.js +19 -18
- package/lib/result.js +16 -0
- package/lib/step/base.js +12 -0
- package/lib/utils.js +2 -10
- package/lib/webServer.js +193 -0
- package/lib/workers.js +118 -31
- package/package.json +4 -2
- package/typings/index.d.ts +60 -7
- package/typings/promiseBasedTypes.d.ts +772 -824
- package/typings/types.d.ts +866 -833
- package/docs/helpers/CDPBrowser.md +0 -2138
package/lib/effects.js
CHANGED
|
@@ -7,6 +7,16 @@ import MetaStep from './step/meta.js'
|
|
|
7
7
|
import { empty } from './assert/empty.js'
|
|
8
8
|
import { isAsyncFunction } from './utils.js'
|
|
9
9
|
|
|
10
|
+
let activeEffects = 0
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Returns true while steps are executed inside tryTo or a retryTo attempt that will be retried
|
|
14
|
+
* @return {boolean}
|
|
15
|
+
*/
|
|
16
|
+
function isEffectActive() {
|
|
17
|
+
return activeEffects > 0
|
|
18
|
+
}
|
|
19
|
+
|
|
10
20
|
/**
|
|
11
21
|
* @param {CodeceptJS.LocatorOrString} context
|
|
12
22
|
* @param {Function} fn
|
|
@@ -117,6 +127,7 @@ class WithinStep extends MetaStep {
|
|
|
117
127
|
let hopeThatFailures = []
|
|
118
128
|
event.dispatcher.on(event.test.before, () => {
|
|
119
129
|
hopeThatFailures = []
|
|
130
|
+
activeEffects = 0
|
|
120
131
|
})
|
|
121
132
|
|
|
122
133
|
async function hopeThat(callback) {
|
|
@@ -214,6 +225,8 @@ async function retryTo(callback, maxTries, pollInterval = 200) {
|
|
|
214
225
|
|
|
215
226
|
const tryBlock = async () => {
|
|
216
227
|
tries++
|
|
228
|
+
const willRetry = tries < maxTries
|
|
229
|
+
if (willRetry) activeEffects++
|
|
217
230
|
recorder.session.start(`${sessionName} ${tries}`)
|
|
218
231
|
try {
|
|
219
232
|
await callback(tries)
|
|
@@ -223,12 +236,14 @@ async function retryTo(callback, maxTries, pollInterval = 200) {
|
|
|
223
236
|
|
|
224
237
|
// Call done if no errors
|
|
225
238
|
recorder.add(() => {
|
|
239
|
+
if (willRetry) activeEffects--
|
|
226
240
|
recorder.session.restore(`${sessionName} ${tries}`)
|
|
227
241
|
done(null)
|
|
228
242
|
})
|
|
229
243
|
|
|
230
244
|
// Catch errors and retry
|
|
231
245
|
recorder.session.catch(err => {
|
|
246
|
+
if (willRetry) activeEffects--
|
|
232
247
|
recorder.session.restore(`${sessionName} ${tries}`)
|
|
233
248
|
if (tries < maxTries) {
|
|
234
249
|
output.debug(`Error ${err}... Retrying`)
|
|
@@ -288,6 +303,7 @@ async function tryTo(callback) {
|
|
|
288
303
|
isAutoRetriesEnabled = store.autoRetries
|
|
289
304
|
if (isAutoRetriesEnabled) output.debug('Auto retries disabled inside tryTo effect')
|
|
290
305
|
store.autoRetries = false
|
|
306
|
+
activeEffects++
|
|
291
307
|
callback()
|
|
292
308
|
recorder.add(() => {
|
|
293
309
|
result = true
|
|
@@ -305,6 +321,7 @@ async function tryTo(callback) {
|
|
|
305
321
|
'result',
|
|
306
322
|
() => {
|
|
307
323
|
store.autoRetries = isAutoRetriesEnabled
|
|
324
|
+
activeEffects--
|
|
308
325
|
return result
|
|
309
326
|
},
|
|
310
327
|
true,
|
|
@@ -316,11 +333,12 @@ async function tryTo(callback) {
|
|
|
316
333
|
)
|
|
317
334
|
}
|
|
318
335
|
|
|
319
|
-
export { hopeThat, retryTo, tryTo, within }
|
|
336
|
+
export { hopeThat, retryTo, tryTo, within, isEffectActive }
|
|
320
337
|
|
|
321
338
|
export default {
|
|
322
339
|
hopeThat,
|
|
323
340
|
retryTo,
|
|
324
341
|
tryTo,
|
|
325
342
|
within,
|
|
343
|
+
isEffectActive,
|
|
326
344
|
}
|