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.
- package/README.md +9 -10
- package/docs/ai.md +3 -51
- package/docs/architecture.md +16 -0
- package/docs/bootstrap.md +1 -1
- package/docs/continuous-integration.md +16 -44
- package/docs/custom-helpers.md +1 -1
- package/docs/detox.md +1 -1
- package/docs/docker.md +1 -30
- package/docs/examples.md +0 -1
- package/docs/helpers/Appium.md +16 -2
- package/docs/helpers/Playwright.md +161 -160
- package/docs/helpers/Puppeteer.md +143 -250
- package/docs/helpers/WebDriver.md +134 -177
- package/docs/hooks.md +11 -1
- package/docs/index.md +1 -1
- package/docs/installation.md +2 -19
- package/docs/locators.md +1 -1
- package/docs/migrate-from-cypress.md +98 -0
- package/docs/migrate-from-java.md +108 -0
- package/docs/migrate-from-protractor.md +101 -0
- package/docs/migrate-from-testcafe.md +99 -0
- package/docs/migration-4.md +195 -8
- package/docs/plugins/aiTrace.md +49 -0
- package/docs/plugins/analyze.md +66 -0
- package/docs/plugins/auth.md +241 -0
- package/docs/plugins/autoDelay.md +48 -0
- package/docs/plugins/browser.md +41 -0
- package/docs/plugins/coverage.md +39 -0
- package/docs/plugins/customLocator.md +119 -0
- package/docs/plugins/customReporter.md +16 -0
- package/docs/plugins/expose.md +75 -0
- package/docs/plugins/heal.md +44 -0
- package/docs/plugins/junitReporter.md +51 -0
- package/docs/plugins/pageInfo.md +34 -0
- package/docs/plugins/pause.md +43 -0
- package/docs/plugins/pauseOnFail.md +18 -0
- package/docs/plugins/retryFailedStep.md +75 -0
- package/docs/plugins/screencast.md +55 -0
- package/docs/plugins/screenshot.md +58 -0
- package/docs/plugins/screenshotOnFail.md +18 -0
- package/docs/plugins/stepTimeout.md +65 -0
- package/docs/plugins.md +40 -862
- package/docs/reports.md +18 -4
- package/docs/retry.md +48 -18
- package/docs/store.md +94 -0
- package/docs/timeouts.md +1 -1
- package/docs/tutorial.md +207 -155
- package/docs/webdriver.md +6 -73
- package/lib/actor.js +0 -35
- package/lib/command/run-multiple.js +1 -2
- package/lib/helper/Playwright.js +1 -15
- package/lib/helper/Puppeteer.js +0 -103
- package/lib/helper/WebDriver.js +1 -28
- package/lib/helper/extras/PlaywrightLocator.js +10 -0
- package/lib/locator.js +0 -13
- package/lib/plugin/analyze.js +3 -4
- package/lib/plugin/pauseOnFail.js +3 -1
- package/lib/plugin/retryFailedStep.js +7 -7
- package/lib/plugin/screenshot.js +0 -5
- package/lib/plugin/screenshotOnFail.js +3 -1
- package/lib/plugin/stepTimeout.js +1 -1
- package/lib/recorder.js +1 -1
- package/lib/workers.js +0 -4
- package/package.json +3 -4
- package/docs/helpers/Mochawesome.md +0 -8
- package/docs/helpers/MockServer.md +0 -212
- package/docs/helpers/Polly.md +0 -44
- package/docs/helpers/Protractor.md +0 -1769
- package/docs/helpers/SoftExpectHelper.md +0 -352
- package/docs/react.md +0 -70
- package/lib/helper/Mochawesome.js +0 -96
- package/lib/helper/extras/PlaywrightReactVueLocator.js +0 -61
- 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
|
|
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
|
-

|
|
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
|
+

|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
31
|
-
waitForAction: 100 //
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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()`
|
|
121
|
+
2. **codeLimitTime** — `step.timeout()`
|
|
122
122
|
3. **stepTimeoutSoft** — plugin with `overrideStepLimits: false`
|
|
123
123
|
4. **testOrSuite** — global test/suite timeout
|
|
124
124
|
|