codeceptjs 4.0.0-rc.23 → 4.0.0-rc.24

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 (73) hide show
  1. package/README.md +9 -10
  2. package/docs/ai.md +3 -51
  3. package/docs/architecture.md +16 -0
  4. package/docs/bootstrap.md +1 -1
  5. package/docs/continuous-integration.md +16 -44
  6. package/docs/custom-helpers.md +1 -1
  7. package/docs/detox.md +1 -1
  8. package/docs/docker.md +1 -30
  9. package/docs/examples.md +0 -1
  10. package/docs/helpers/Appium.md +16 -2
  11. package/docs/helpers/Playwright.md +161 -160
  12. package/docs/helpers/Puppeteer.md +143 -250
  13. package/docs/helpers/WebDriver.md +134 -177
  14. package/docs/hooks.md +11 -1
  15. package/docs/index.md +1 -1
  16. package/docs/installation.md +2 -19
  17. package/docs/locators.md +1 -1
  18. package/docs/migrate-from-cypress.md +98 -0
  19. package/docs/migrate-from-java.md +108 -0
  20. package/docs/migrate-from-protractor.md +101 -0
  21. package/docs/migrate-from-testcafe.md +99 -0
  22. package/docs/migration-4.md +195 -8
  23. package/docs/plugins/aiTrace.md +49 -0
  24. package/docs/plugins/analyze.md +66 -0
  25. package/docs/plugins/auth.md +241 -0
  26. package/docs/plugins/autoDelay.md +48 -0
  27. package/docs/plugins/browser.md +41 -0
  28. package/docs/plugins/coverage.md +39 -0
  29. package/docs/plugins/customLocator.md +119 -0
  30. package/docs/plugins/customReporter.md +16 -0
  31. package/docs/plugins/expose.md +75 -0
  32. package/docs/plugins/heal.md +44 -0
  33. package/docs/plugins/junitReporter.md +51 -0
  34. package/docs/plugins/pageInfo.md +34 -0
  35. package/docs/plugins/pause.md +43 -0
  36. package/docs/plugins/pauseOnFail.md +18 -0
  37. package/docs/plugins/retryFailedStep.md +75 -0
  38. package/docs/plugins/screencast.md +55 -0
  39. package/docs/plugins/screenshot.md +58 -0
  40. package/docs/plugins/screenshotOnFail.md +18 -0
  41. package/docs/plugins/stepTimeout.md +65 -0
  42. package/docs/plugins.md +40 -862
  43. package/docs/reports.md +18 -4
  44. package/docs/retry.md +48 -18
  45. package/docs/store.md +94 -0
  46. package/docs/timeouts.md +1 -1
  47. package/docs/tutorial.md +207 -155
  48. package/docs/webdriver.md +6 -73
  49. package/lib/actor.js +0 -35
  50. package/lib/command/run-multiple.js +1 -2
  51. package/lib/helper/Playwright.js +1 -15
  52. package/lib/helper/Puppeteer.js +0 -103
  53. package/lib/helper/WebDriver.js +1 -28
  54. package/lib/helper/extras/PlaywrightLocator.js +10 -0
  55. package/lib/locator.js +0 -13
  56. package/lib/plugin/analyze.js +3 -4
  57. package/lib/plugin/pauseOnFail.js +3 -1
  58. package/lib/plugin/retryFailedStep.js +7 -7
  59. package/lib/plugin/screenshot.js +0 -5
  60. package/lib/plugin/screenshotOnFail.js +3 -1
  61. package/lib/plugin/stepTimeout.js +1 -1
  62. package/lib/recorder.js +1 -1
  63. package/lib/workers.js +0 -4
  64. package/package.json +3 -4
  65. package/docs/helpers/Mochawesome.md +0 -8
  66. package/docs/helpers/MockServer.md +0 -212
  67. package/docs/helpers/Polly.md +0 -44
  68. package/docs/helpers/Protractor.md +0 -1769
  69. package/docs/helpers/SoftExpectHelper.md +0 -352
  70. package/docs/react.md +0 -70
  71. package/lib/helper/Mochawesome.js +0 -96
  72. package/lib/helper/extras/PlaywrightReactVueLocator.js +0 -61
  73. package/lib/helper/extras/React.js +0 -65
package/docs/reports.md CHANGED
@@ -21,13 +21,19 @@ plugins: {
21
21
  testomatio: {
22
22
  enabled: true,
23
23
  require: '@testomatio/reporter/codecept',
24
+ html: true,
25
+ markdown: true,
26
+ csv: true,
27
+ reportDir: 'output/report',
24
28
  },
25
29
  }
26
30
  ```
27
31
 
32
+ The local reports above are enabled directly from CodeceptJS config. If `reportDir` is omitted, reports are written to `output/report` using the CodeceptJS `output` directory.
33
+
28
34
  ### Enable an output
29
35
 
30
- Each output turns on when you set its environment variable. Run your tests as usual one run feeds every output you enabled.
36
+ Each output can also be enabled with environment variables. Run your tests as usual and one run feeds every output you enabled.
31
37
 
32
38
  | To get… | Set | Details |
33
39
  | --- | --- | --- |
@@ -63,7 +69,9 @@ The GitHub pipe also needs the job to grant `permissions: pull-requests: write`.
63
69
 
64
70
  A single self-contained HTML file with the run summary and, per test, its steps, screenshots, logs, and error. It needs no API key and no service, so it works anywhere — open it locally or attach it to a CI build.
65
71
 
66
- ![HTML report](https://raw.githubusercontent.com/testomatio/reporter/master/docs/pipes/images/html-pipe.png)
72
+ ![HTML report](./images/testomatio-html-report.png)
73
+
74
+ - Preferred in CodeceptJS 4: enable `html: true` in `plugins.testomatio` and run `npx codeceptjs run`
67
75
 
68
76
  - `TESTOMATIO_HTML_REPORT_SAVE=1` — enable the report
69
77
  - `TESTOMATIO_HTML_REPORT_FOLDER=output/reports` — keep it inside CodeceptJS's `output/` dir (default folder is `html-report`)
@@ -118,6 +126,10 @@ Posts a comment to the Pull Request with the same summary. Comments are created
118
126
 
119
127
  ### Markdown Report
120
128
 
129
+ - Preferred in CodeceptJS 4: enable `markdown: true` in `plugins.testomatio` and run `npx codeceptjs run`
130
+
131
+ ![Markdown report](./images/testomatio-markdown-report.png)
132
+
121
133
  A single self-contained Markdown file — renders in PR comments, CI job summaries, and Slack, and is convenient for AI agents reading test results. Needs no API key.
122
134
 
123
135
  - `TESTOMATIO_MARKDOWN_REPORT_SAVE=1` — enable the report
@@ -161,12 +173,14 @@ plugins: {
161
173
 
162
174
  Hooks: `onHookFinished`, `onTestBefore`, `onTestPassed`, `onTestFailed`, `onTestSkipped`, `onTestFinished`, `onResult`.
163
175
 
164
- For Mocha reporters, use `--reporter`:
176
+ For built-in Mocha reporters, use `--reporter`:
165
177
 
166
178
  ```sh
167
- npx codeceptjs run --reporter mochawesome --reporter-options reportDir=output
179
+ npx codeceptjs run --reporter dot
168
180
  ```
169
181
 
182
+ > The bundled `Mochawesome` helper was removed in 4.x. For an HTML report use the [Testomat.io Reporter](https://github.com/testomatio/reporter) HTML pipe (see above); for JUnit XML use the [`junitReporter`](#junit-xml) plugin. Wiring multiple Mocha reporters through `mocha-multi`/`cmr` is not recommended — prefer these instead.
183
+
170
184
  Plugins exist for [TestRail](https://www.npmjs.com/package/codeceptjs-testrail) and [Tesults](https://www.npmjs.com/package/codeceptjs-tesults).
171
185
 
172
186
  ## CLI output
package/docs/retry.md CHANGED
@@ -20,24 +20,36 @@ CodeceptJS provides flexible retry mechanisms to handle flaky tests. Use retries
20
20
 
21
21
  ## Helper Retries
22
22
 
23
- Browser automation helpers (Playwright, Puppeteer, WebDriver) have **built-in retry mechanisms** for element interactions. When you call `I.click('Button')`, Playwright automatically waits for the element to exist, be visible, stable, and enabled retrying for up to 5 seconds.
23
+ Plawright has a built-in retry mechanism for element interactions. When you call `I.click('Button')`, after the element is located Playwright keeps retrying until it is actionable up to `timeout` (default 5s).
24
24
 
25
- Configure the timeout in your helper settings:
25
+ > WebDriver has a different auto-retry option: [smartWait](/webdriver#smartwait)
26
+
27
+ Even though the handle exists (from `.all()`), Playwright still waits for it to become visible, stable (not mid-animation), enabled, not covered by an overlay/modal, and not rerendering.
26
28
 
27
29
  ```js
28
30
  helpers: {
29
31
  Playwright: {
30
- timeout: 5000, // retry actions for up to 5 seconds
31
- waitForAction: 100 // wait 100ms before each action
32
+ timeout: 5000, // retry the action until the element is actionable
33
+ waitForAction: 100 // fixed pause AFTER click/doubleClick/pressKey
32
34
  }
33
35
  }
34
36
  ```
35
37
 
36
- **Learn more:** [Playwright Helper](/helpers/Playwright), [Timeouts](/timeouts)
38
+ What each setting does:
39
+
40
+ ```
41
+ find element (no wait — fails instantly if locator matches nothing)
42
+ → wait up to `timeout` for it to become actionable ← timeout
43
+ → perform action
44
+ → sleep `waitForAction` ms ← waitForAction (settle pause, not a wait)
45
+ ```
46
+
47
+ `timeout` covers the action. If the locator matches nothing yet, the step fails immediately. Use [Failed Step Retries](#failed-step-retries) to cover that gap.
48
+
37
49
 
38
50
  ## Failed Step Retries
39
51
 
40
- Automatically retry all failed steps without modifying test code:
52
+ CodeceptJS retries all failed steps by default by using the `retryFailedStep` plugin.
41
53
 
42
54
  ```js
43
55
  plugins: {
@@ -66,18 +78,36 @@ Scenario('manual retries only', { disableRetryFailedStep: true }, ({ I }) => {
66
78
  })
67
79
  ```
68
80
 
69
- Full plugin options:
70
-
71
- | Option | Default | Description |
72
- |--------|---------|-------------|
73
- | `retries` | — | Retries per step |
74
- | `minTimeout` | | Milliseconds before first retry |
75
- | `maxTimeout` | `Infinity` | Max milliseconds between retries |
76
- | `factor` | — | Exponential backoff multiplier |
77
- | `randomize` | `false` | Randomize timeout intervals |
78
- | `ignoredSteps` | `[]` | Patterns/regex of steps to never retry |
79
- | `deferToScenarioRetries` | `true` | Disable step retries when scenario retries exist |
80
- | `when` | `() => true` | Function receiving error; return `true` to retry |
81
+ Defaults: `minTimeout: 150`, `factor: 1.5`, `maxTimeout: 10000`.
82
+
83
+
84
+ > See [plugin reference](/plugins/retry-failed-step) for more options
85
+
86
+ Retries are calculated via this formula:
87
+
88
+ ```
89
+ gap(N) = min(minTimeout × factor^(N-1), maxTimeout)
90
+ ```
91
+
92
+ Practically if step fails it will trigger a retry with increasing delay until `maxTimeout` is reached:
93
+
94
+ ```
95
+ retries: 2 => 0.15s-0.4s (150,225ms)
96
+ retries: 3 => 0.15s-0.7s (150,225,338ms)
97
+ retries: 3, minTimeout: 1000 => 1s-4.75s (1s,1.5s,2.25s)
98
+ retries: 3, minTimeout: 1000, factor: 2 => 1s-7s (1s,2s,4s)
99
+ retries: 5, minTimeout: 1000, factor: 2 => 1s-25s (1s,2s,4s,8s,10s)
100
+ ```
101
+
102
+ Playwright `timeout` adds to each attempt only when the element is found:
103
+
104
+ - `Playwright.timeout: 5000`
105
+ - `retries: 2, minTimeout: 1000`
106
+
107
+ ```
108
+ element not found => 0 + (1s+1s) = 2s
109
+ element found but not interactable => 3×5s + (1s+1s) = 17s
110
+ ```
81
111
 
82
112
  ## Manual Step Retries
83
113
 
package/docs/store.md ADDED
@@ -0,0 +1,94 @@
1
+ ---
2
+ permalink: /store
3
+ title: Store
4
+ ---
5
+
6
+ # Store
7
+
8
+ `store` is a global object that holds the state of the current run — which test and step are executing, which modes are enabled, and where the project lives on disk. Listeners, plugins, and helpers read it to find out *where in the lifecycle* they are without threading that information through every call.
9
+
10
+ ```js
11
+ import { store } from 'codeceptjs'
12
+
13
+ event.dispatcher.on(event.step.before, () => {
14
+ if (store.dryRun) return // skip side effects on a dry run
15
+ console.log(`running ${store.currentTest?.title}`)
16
+ })
17
+ ```
18
+
19
+ It is a single shared object for the whole process. Read from it freely; write to it only if you are deliberately driving execution state (see [Writing to the store](#writing-to-the-store)).
20
+
21
+ ## Fields
22
+
23
+ ### Required
24
+
25
+ Set once when the runner starts and immutable afterwards. Resolved from the test root, falling back to the legacy `global.codecept_dir` / `global.output_dir`.
26
+
27
+ | Field | Type | What it is |
28
+ | --- | --- | --- |
29
+ | `store.codeceptDir` | `string` | root directory of the tests |
30
+ | `store.outputDir` | `string` | resolved output directory for artifacts |
31
+ | `store.workerMode` | `boolean` | `true` when running inside a [parallel](/parallel) worker |
32
+
33
+ ### Session config
34
+
35
+ Set at session start and stable for that session. They reflect how the run was invoked.
36
+
37
+ | Field | Type | What it is |
38
+ | --- | --- | --- |
39
+ | `store.debugMode` | `boolean` | run started with `--debug` |
40
+ | `store.timeouts` | `boolean` | [timeouts](/timeouts) are enabled |
41
+ | `store.autoRetries` | `boolean` | step auto-retries are active (the `tryTo` [effect](/effects) turns this off while it runs) |
42
+ | `store.dryRun` | `boolean` | run is a `--dry-run`; steps must not cause side effects |
43
+ | `store.featureOnly` | `boolean` | a `Feature.only()` was used |
44
+ | `store.scenarioOnly` | `boolean` | a `Scenario.only()` was used |
45
+ | `store.maskSensitiveData` | `boolean \| object` | mask [secret](/secrets) values in output |
46
+ | `store.noGlobals` | `boolean` | `noGlobals` mode — the user imports everything instead of relying on globals |
47
+
48
+ ### State
49
+
50
+ Changes constantly as the run progresses. The most useful fields for plugins and listeners:
51
+
52
+ | Field | Type | What it is |
53
+ | --- | --- | --- |
54
+ | `store.onPause` | `boolean` | execution is paused inside [`pause()`](/basics#pause) |
55
+ | `store.currentTest` | `Test \| null` | the running test, or `null` between tests |
56
+ | `store.currentStep` | `Step \| null` | the running step, or `null` |
57
+ | `store.currentSuite` | `Suite \| null` | the running suite, or `null` between suites |
58
+ | `store.tsFileMapping` | `Map \| null` | TypeScript source-map lookup, when running `.ts` tests |
59
+
60
+ `currentTest`, `currentStep`, and `currentSuite` carry the same objects passed to lifecycle events — see the [test and step object](/architecture#test-object) fields.
61
+
62
+ ## Reading the store
63
+
64
+ A typical use is gating expensive or unsafe work by run mode:
65
+
66
+ ```js
67
+ import { store, recorder } from 'codeceptjs'
68
+
69
+ event.dispatcher.on(event.test.before, () => {
70
+ if (store.dryRun || store.workerMode) return
71
+
72
+ recorder.add('seed fixture data', async () => {
73
+ await api.post('/users', { name: 'john' })
74
+ })
75
+ })
76
+ ```
77
+
78
+ `store.currentTest` is the simplest way to attach context to the current test from anywhere — for example tagging an artifact:
79
+
80
+ ```js
81
+ import { store } from 'codeceptjs'
82
+
83
+ store.currentTest?.artifacts.push({ name: 'log', path: '/tmp/run.log' })
84
+ ```
85
+
86
+ ## Writing to the store
87
+
88
+ CodeceptJS keeps the state fields current for you — the built-in [`store` listener](https://github.com/codeceptjs/CodeceptJS/blob/master/lib/listener/store.js) sets `currentSuite` and `currentTest` around each suite and test. You rarely need to write to it.
89
+
90
+ Write only when you are deliberately driving execution — for example, a tool that opens `pause()` sets `store.onPause`. The required fields (`codeceptDir`, `outputDir`) are locked after `store.initialize()` and cannot be reassigned.
91
+
92
+ ---
93
+
94
+ **See also:** [Architecture](/architecture) · [Extending CodeceptJS](/hooks) · [Events](/architecture#events)
package/docs/timeouts.md CHANGED
@@ -118,7 +118,7 @@ plugins: {
118
118
  When multiple timeouts are configured, CodeceptJS applies them in priority order:
119
119
 
120
120
  1. **stepTimeoutHard** — plugin with `overrideStepLimits: true`
121
- 2. **codeLimitTime** — `step.timeout()` or `I.limitTime()`
121
+ 2. **codeLimitTime** — `step.timeout()`
122
122
  3. **stepTimeoutSoft** — plugin with `overrideStepLimits: false`
123
123
  4. **testOrSuite** — global test/suite timeout
124
124