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.
Files changed (63) hide show
  1. package/README.md +2 -0
  2. package/bin/codecept.js +11 -0
  3. package/docs/agents.md +26 -1
  4. package/docs/ai.md +57 -0
  5. package/docs/alternative-browsers.md +175 -148
  6. package/docs/assertions.md +74 -0
  7. package/docs/bootstrap.md +2 -0
  8. package/docs/commands.md +45 -0
  9. package/docs/configuration.md +37 -0
  10. package/docs/debugging.md +1 -1
  11. package/docs/helpers/ApiDataFactory.md +20 -20
  12. package/docs/helpers/Appium.md +1615 -670
  13. package/docs/helpers/Decision.md +146 -0
  14. package/docs/helpers/GraphQL.md +31 -31
  15. package/docs/helpers/GraphQLDataFactory.md +20 -20
  16. package/docs/helpers/Kitesurf.md +1808 -25
  17. package/docs/helpers/Lightpanda.md +139 -0
  18. package/docs/helpers/Obscura.md +1799 -74
  19. package/docs/helpers/Playwright.md +490 -428
  20. package/docs/helpers/Puppeteer.md +317 -255
  21. package/docs/helpers/REST.md +43 -43
  22. package/docs/helpers/WebDriver.md +237 -175
  23. package/docs/installation.md +16 -0
  24. package/docs/mcp.md +7 -1
  25. package/docs/parallel.md +35 -1
  26. package/docs/plugins/pause.md +2 -1
  27. package/docs/plugins/sitemap.md +48 -0
  28. package/docs/plugins.md +4 -0
  29. package/lib/ai.js +81 -2
  30. package/lib/codecept.js +32 -2
  31. package/lib/command/init.js +22 -0
  32. package/lib/command/initAgent.js +78 -0
  33. package/lib/command/run-multiple.js +3 -0
  34. package/lib/command/run-workers.js +10 -3
  35. package/lib/command/run.js +3 -2
  36. package/lib/command/utils.js +15 -0
  37. package/lib/command/workers/runTests.js +10 -10
  38. package/lib/container.js +4 -2
  39. package/lib/effects.js +19 -1
  40. package/lib/helper/CDPBrowser.js +349 -1384
  41. package/lib/helper/Decision.js +256 -0
  42. package/lib/helper/Kitesurf.js +3 -21
  43. package/lib/helper/Lightpanda.js +137 -0
  44. package/lib/helper/Obscura.js +21 -238
  45. package/lib/helper/Playwright.js +6 -4
  46. package/lib/helper/Puppeteer.js +12 -7
  47. package/lib/helper/WebDriver.js +2 -1
  48. package/lib/listener/result.js +4 -0
  49. package/lib/mocha/bdd.js +19 -1
  50. package/lib/plugin/junitReporter.js +4 -1
  51. package/lib/plugin/pause.js +4 -1
  52. package/lib/plugin/sitemap.js +228 -0
  53. package/lib/recorder.js +19 -18
  54. package/lib/result.js +16 -0
  55. package/lib/step/base.js +12 -0
  56. package/lib/utils.js +2 -10
  57. package/lib/webServer.js +193 -0
  58. package/lib/workers.js +118 -31
  59. package/package.json +4 -2
  60. package/typings/index.d.ts +60 -7
  61. package/typings/promiseBasedTypes.d.ts +772 -824
  62. package/typings/types.d.ts +866 -833
  63. 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
  }