Skip to content

Commit 87a25ad

Browse files
DavertMikDavertMikclaude
authored
feat(plugins): unify screenshot/pause/aiTrace/heal under shared on= parameter (#5542)
* update docs * updated docs, added browser plugin * feat(plugins): unify screenshot/pause/aiTrace/heal under shared on= parameter Adds a shared lib/utils/pluginParser.js with key=value parsing (`:` and `;` separators) and a `resolveTrigger` helper. Renames screenshotOnFail → screenshot and consolidates pauseOn/pauseOnFail → pause; aiTrace and heal grow `on=` filters. Old plugin names live on as deprecated alias shims that warn and forward. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(plugins): drop pauseOn/stepByStepReport, fold slides into screenshot - Remove lib/plugin/pauseOn.js (never shipped in a public release). - Remove lib/plugin/stepByStepReport.js; slideshow generation moves into the screenshot plugin behind slides=true (e.g. -p screenshot:on=step;slides=true) with a modern, vanilla-CSS dark UI — no Bootstrap, no jQuery. - Drop the redundant screenshot blocks from the acceptance test configs; the default in lib/config.js already enables screenshot with on=fail. - Strip allure mentions from plugin code and plugin docs; refresh PR template, migration guide, debugging guide, plugins index, and commands docs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(plugins): centralize on= validation in resolveTrigger resolveTrigger now takes { name, validModes }, performs the unknown-mode and missing-path/pattern checks itself, prints the error via output.error, and returns null. Each plugin shrinks to one call + early-return; heal passes its narrower mode list as { validModes: ['fail', 'file', 'url'] }. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: DavertMik <davert@testomat.io> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5ce3c9f commit 87a25ad

25 files changed

Lines changed: 1075 additions & 947 deletions

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,17 @@ Applicable helpers:
1313

1414
Applicable plugins:
1515

16-
- [ ] allure
16+
- [ ] aiTrace
1717
- [ ] autoDelay
1818
- [ ] autoLogin
1919
- [ ] customLocator
20-
- [ ] pauseOnFail
20+
- [ ] pause
2121
- [ ] coverage
22+
- [ ] heal
2223
- [ ] retryFailedStep
23-
- [ ] screenshotOnFail
24+
- [ ] screenshot
2425
- [ ] selenoid
25-
- [ ] stepByStepReport
2626
- [ ] stepTimeout
27-
- [ ] wdio
2827
- [ ] subtitles
2928

3029
## Type of change

docs/commands.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ Plugins listed via `-p` are activated even when their config has `enabled: false
115115
A few examples:
116116

117117
```sh
118-
npx codeceptjs run -p pauseOnFail # pause on first failure
119-
npx codeceptjs run -p pauseOn:step # pause before every step
120-
npx codeceptjs run -p pauseOn:url:/checkout/* # pause on URL match
121-
npx codeceptjs run -p stepByStepReport # produce a step-by-step HTML report
118+
npx codeceptjs run -p pause # pause on first failure (default on=fail)
119+
npx codeceptjs run -p pause:on=step # pause before every step
120+
npx codeceptjs run -p pause:on=url:pattern=/checkout/* # pause on URL match
121+
npx codeceptjs run -p "screenshot:on=step;slides=true" # produce a step-by-step HTML report
122122
```
123123

124124
### Browser Control

docs/configuration.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,14 @@ import { setCommonPlugins } from '@codeceptjs/configure'
194194
setCommonPlugins()
195195
```
196196

197-
| Plugin | Default | Notes |
198-
| :----------------- | :------------- | :----------------------------------------------------------------------------- |
199-
| `retryFailedStep` | enabled | Retry steps that fail with transient errors |
200-
| `screenshotOnFail` | enabled | Capture a screenshot when a test fails |
201-
| `pauseOn` | registered | Pause on failure / step / file / URL — `-p pauseOn:fail`, `-p pauseOn:step`, `-p pauseOn:file:tests/login_test.js`, `-p pauseOn:url:/checkout/*` |
202-
| `browser` | registered | CLI overrides for browser helpers — `-p browser:show`, `-p browser:browser=firefox`, see [commands](/commands#browser-control) |
203-
| `aiTrace` | registered | Capture AI traces — `-p aiTrace` |
197+
| Plugin | Default | Notes |
198+
| :---------------- | :------------- | :----------------------------------------------------------------------------- |
199+
| `retryFailedStep` | enabled | Retry steps that fail with transient errors |
200+
| `screenshot` | enabled | Screenshot on `fail` (default) / `test` / `step` / `file` / `url` |
201+
| `pause` | registered | Pause on failure / step / file / URL — `-p pause:on=fail`, `-p pause:on=step`, `-p pause:on=file:path=tests/login_test.js`, `-p pause:on=url:pattern=/checkout/*` |
202+
| `browser` | registered | CLI overrides for browser helpers — `-p browser:show`, `-p browser:browser=firefox`, see [commands](/commands#browser-control) |
203+
| `aiTrace` | registered | Capture AI traces — `-p aiTrace`, narrow with `on=fail|test|step|file|url` |
204+
| `heal` | registered | Self-heal failing steps — `-p heal`, narrow with `on=file|url` |
204205

205206
> `eachElement`, `tryTo`, and `retryTo` are no longer plugins in 4.x — import them from `codeceptjs/effects`.
206207

docs/debugging.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,28 +107,30 @@ After(({ I }) => {
107107
})
108108
```
109109

110-
## Pause On Plugin
110+
## Pause Plugin
111111

112-
For automated debugging without modifying test code, use the `pauseOn` plugin. It pauses tests based on different triggers, controlled entirely from the command line.
112+
For automated debugging without modifying test code, use the `pause` plugin. It pauses tests based on different triggers, controlled entirely from the command line. The default is `on=fail`.
113113

114114
### Pause on Failure
115115

116116
Automatically enters interactive pause when a step fails:
117117

118118
```bash
119-
npx codeceptjs run -p pauseOn:fail
119+
npx codeceptjs run -p pause
120+
# or, explicit:
121+
npx codeceptjs run -p pause:on=fail
120122
```
121123

122124
This is the most common debug workflow — run your tests, and when one fails, you land in the interactive shell with the browser in the exact state of the failure. You can inspect elements, try different selectors, and figure out what went wrong.
123125

124-
> The older `pauseOnFail` plugin still works: `npx codeceptjs run -p pauseOnFail`
126+
> The legacy `pauseOnFail` plugin still works as a deprecated alias.
125127
126128
### Pause on Every Step
127129

128130
Enters interactive pause at the start of the test. Use *ENTER* to advance step by step:
129131

130132
```bash
131-
npx codeceptjs run -p pauseOn:step
133+
npx codeceptjs run -p pause:on=step
132134
```
133135

134136
This gives you full step-by-step execution. After each step, you're back in the interactive shell where you can inspect the page before pressing ENTER to continue.
@@ -138,13 +140,13 @@ This gives you full step-by-step execution. After each step, you're back in the
138140
Pauses when execution reaches a specific file:
139141

140142
```bash
141-
npx codeceptjs run -p pauseOn:file:tests/login_test.js
143+
npx codeceptjs run -p pause:on=file:path=tests/login_test.js
142144
```
143145

144146
With a specific line number:
145147

146148
```bash
147-
npx codeceptjs run -p pauseOn:file:tests/login_test.js:43
149+
npx codeceptjs run -p pause:on=file:path=tests/login_test.js;line=43
148150
```
149151

150152
This works like a breakpoint — the test runs normally until it hits a step defined at that file and line, then opens the interactive shell.
@@ -154,14 +156,14 @@ This works like a breakpoint — the test runs normally until it hits a step def
154156
Pauses when the browser navigates to a matching URL:
155157

156158
```bash
157-
npx codeceptjs run -p pauseOn:url:/users/1
159+
npx codeceptjs run -p pause:on=url:pattern=/users/1
158160
```
159161

160162
Supports `*` wildcards:
161163

162164
```bash
163-
npx codeceptjs run -p pauseOn:url:/api/*/edit
164-
npx codeceptjs run -p pauseOn:url:/checkout/*
165+
npx codeceptjs run -p pause:on=url:pattern=/api/*/edit
166+
npx codeceptjs run -p pause:on=url:pattern=/checkout/*
165167
```
166168

167169
This is useful when you want to inspect a specific page regardless of which test step navigates there.
@@ -243,15 +245,16 @@ Enabled by default. Saves a screenshot when a test fails:
243245

244246
```js
245247
plugins: {
246-
screenshotOnFail: {
248+
screenshot: {
247249
enabled: true,
250+
on: 'fail',
248251
uniqueScreenshotNames: true,
249252
fullPageScreenshots: true,
250253
}
251254
}
252255
```
253256

254-
Screenshots are saved in the `output` directory.
257+
Screenshots are saved in the `output` directory. The same plugin also supports `on=test`, `on=step`, `on=file`, and `on=url` to capture screenshots in other situations.
255258

256259
### Page Info on Failure
257260

@@ -267,20 +270,22 @@ plugins: {
267270

268271
### Step-by-Step Report
269272

270-
Generates a slideshow of screenshots taken after every step — a visual replay of what the test did:
273+
Generates a slideshow of screenshots taken after every step — a visual replay of what the test did. Set `slides: true` on the `screenshot` plugin (with `on=step`):
271274

272275
```js
273276
plugins: {
274-
stepByStepReport: {
277+
screenshot: {
275278
enabled: true,
279+
on: 'step',
280+
slides: true,
276281
deleteSuccessful: true, // keep only failed tests
277282
fullPageScreenshots: true,
278283
}
279284
}
280285
```
281286

282287
```bash
283-
npx codeceptjs run -p stepByStepReport
288+
npx codeceptjs run -p screenshot:on=step;slides=true
284289
```
285290

286291
After the run, open `output/records.html` to browse through the slideshows.

docs/migration-4.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,21 @@ plugins: {
187187

188188
Inject `login` and call `login('admin')` — same as before.
189189

190+
### Renamed Plugins
191+
192+
4.x unifies four plugins (`screenshot`, `pause`, `aiTrace`, `heal`) under a shared `on=` parameter. The old names live on as deprecated aliases that emit a warning and forward to the new plugin.
193+
194+
| Old plugin | New plugin | Notes |
195+
| :------------------ | :------------------------------- | :------------------------------------------------- |
196+
| `screenshotOnFail` | `screenshot` | Default `on='fail'`, same behavior |
197+
| `pauseOnFail` | `pause` | Default `on='fail'`, same behavior |
198+
| `stepByStepReport` | `screenshot` with `slides: true` | Use `on=step` to capture every step |
199+
190200
### New Plugins You Can Enable
191201

192202
- **`aiTrace`** — captures failure traces (DOM, console, network, screenshots) for AI debugging. See [AI Trace](/aitrace).
193-
- **`pauseOn`** — pauses execution on a chosen event or on failure. See [Debugging](/debugging).
203+
- **`pause`** — pauses execution on a chosen event or on failure. See [Debugging](/debugging).
204+
- **`heal`** — self-heals failing steps with AI; narrow with `on=file|url`.
194205

195206
## 5. Update Removed and Changed APIs
196207

@@ -455,13 +466,16 @@ I.fillField('input', 'x', step.opts({ elementIndex: -1 }))
455466
`-p` accepts colon-chained arguments, so plugins can be enabled and configured from the command line without editing config:
456467
457468
```bash
458-
npx codeceptjs run -p pauseOn:fail # pause on every failure
459-
npx codeceptjs run -p pauseOn:url:/checkout/* # pause when URL matches
460-
npx codeceptjs run -p browser:show # force visible browser
469+
npx codeceptjs run -p pause # pause on every failure
470+
npx codeceptjs run -p pause:on=url:pattern=/checkout/* # pause when URL matches
471+
npx codeceptjs run -p screenshot:on=step # screenshot every step
472+
npx codeceptjs run -p browser:show # force visible browser
461473
npx codeceptjs run -p browser:browser=firefox:windowSize=1024x768
462-
npx codeceptjs run -p plugin1,plugin2:arg # multiple plugins
474+
npx codeceptjs run -p plugin1,plugin2:arg # multiple plugins
463475
```
464476
477+
Each argument after the plugin name is a `key=value` pair. `:` separates pairs. `;` is an inline alternative for visually grouping related pairs (e.g. `path=...;line=...`). Reserved keys: `on`, `path`, `line`, `pattern`.
478+
465479
The `browser` plugin is new in 4.x — it overrides the active browser helper (Playwright, Puppeteer, WebDriver, Appium) from the CLI, useful for ad-hoc local runs and CI matrices. See [Commands](/commands).
466480
467481
The old `-p all` magic keyword is gone (it conflicted with the colon syntax). Enable specific plugins explicitly: `-p pluginA,pluginB`.

docs/plugins.md

Lines changed: 61 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -595,47 +595,42 @@ Additional config options:
595595
596596
* `config` (optional, default `{}`)
597597
598-
## pauseOn
598+
## pause
599599
600-
Pauses test execution in different modes. Unlike `pauseOnFail`, this plugin supports
601-
multiple triggers for pausing and is controlled via CLI arguments.
600+
Pauses test execution interactively. Replaces the legacy `pauseOnFail` plugin.
601+
Default `on=fail` matches the old `pauseOnFail` behavior.
602602
603-
Enable it via `-p` option with a mode:
604-
605-
npx codeceptjs run -p pauseOn:fail
606-
npx codeceptjs run -p pauseOn:step
607-
npx codeceptjs run -p pauseOn:file:tests/login_test.js
608-
npx codeceptjs run -p pauseOn:file:tests/login_test.js:43
609-
npx codeceptjs run -p pauseOn:url:/users/*
610-
611-
#### Modes
612-
613-
* **fail** — pause when a step fails (same as `pauseOnFail` plugin)
614-
* **step** — pause before first step, use `next` to advance step-by-step
615-
* **file** — pause when execution reaches a specific file (and optionally line)
616-
* **url** — pause when the browser URL matches a pattern (supports `*` wildcards)
603+
```js
604+
plugins: {
605+
pause: {
606+
enabled: false,
607+
on: 'fail',
608+
}
609+
}
610+
```
617611
618-
### Parameters
612+
#### `on=` modes
619613
620-
* `config` (optional, default `{}`)
614+
* **fail** — pause when a step fails (default)
615+
* **test** — pause after each test
616+
* **step** — pause before the first step (interactive walk-through)
617+
* **file** — pause when execution reaches `path=...[;line=...]`
618+
* **url** — pause when the current URL matches `pattern=...`
621619
622-
## pauseOnFail
620+
CLI examples:
623621
624-
Automatically launches [interactive pause][5] when a test fails.
622+
npx codeceptjs run -p pause
623+
npx codeceptjs run -p pause:on=step
624+
npx codeceptjs run -p pause:on=file:path=tests/login_test.js
625+
npx codeceptjs run -p pause:on=file:path=tests/login_test.js;line=43
626+
npx codeceptjs run -p pause:on=url:pattern=/users/*
625627
626-
Useful for debugging flaky tests on local environment.
627-
Add this plugin to config file:
628+
> The legacy `pauseOnFail` plugin remains as a deprecated alias that emits a
629+
> deprecation warning and forwards to `pause` with `on=fail`.
628630
629-
```js
630-
plugins: {
631-
pauseOnFail: {},
632-
}
633-
```
634-
635-
Unlike other plugins, `pauseOnFail` is not recommended to be enabled by default.
636-
Enable it manually on each run via `-p` option:
631+
### Parameters
637632
638-
npx codeceptjs run -p pauseOnFail
633+
* `config` (optional, default `{}`)
639634
640635
## retryFailedStep
641636
@@ -705,70 +700,60 @@ Scenario('scenario tite', { disableRetryFailedStep: true }, () => {
705700
706701
* `config` &#x20;
707702
708-
## screenshotOnFail
709-
710-
Creates screenshot on failure. Screenshot is saved into `output` directory.
703+
## screenshot
711704
712-
Initially this functionality was part of corresponding helper but has been moved into plugin since 1.4
705+
Saves screenshots from the browser at points triggered by `on=`. Replaces the
706+
legacy `screenshotOnFail` plugin. Default `on=fail` preserves the old behavior.
713707
714708
This plugin is **enabled by default**.
715709
716-
#### Configuration
717-
718-
Configuration can either be taken from a corresponding helper (deprecated) or a from plugin config (recommended).
719-
720710
```js
721711
plugins: {
722-
screenshotOnFail: {
723-
enabled: true
724-
}
712+
screenshot: {
713+
enabled: true,
714+
on: 'fail',
715+
}
725716
}
726717
```
727718
728-
Possible config options:
729-
730-
* `uniqueScreenshotNames`: use unique names for screenshot. Default: false.
731-
* `fullPageScreenshots`: make full page screenshots. Default: false.
732-
733-
### Parameters
719+
#### `on=` modes
734720
735-
* `config` &#x20;
736-
737-
## stepByStepReport
738-
739-
![step-by-step-report][6]
721+
* **fail** — screenshot when a test fails (default)
722+
* **test** — screenshot at the end of every test
723+
* **step** — screenshot after every step
724+
* **file** — screenshot for steps in `path=...[;line=...]`
725+
* **url** — screenshot when the current URL matches `pattern=...`
740726
741-
Generates step by step report for a test.
742-
After each step in a test a screenshot is created. After test executed screenshots are combined into slideshow.
743-
By default, reports are generated only for failed tests.
727+
CLI examples:
744728
745-
Run tests with plugin enabled:
729+
npx codeceptjs run -p screenshot
730+
npx codeceptjs run -p screenshot:on=step
731+
npx codeceptjs run -p screenshot:on=step;slides=true
732+
npx codeceptjs run -p screenshot:on=file:path=tests/login_test.js
733+
npx codeceptjs run -p screenshot:on=url:pattern=/users/*
746734
747-
npx codeceptjs run --plugins stepByStepReport
735+
Possible config options:
748736
749-
#### Configuration
737+
* `uniqueScreenshotNames`: use unique names for screenshot. Default: false.
738+
* `fullPageScreenshots`: make full page screenshots. Default: false.
739+
* `slides`: generate a step-by-step slideshow report (works with `on=step|file|url`). Replaces the legacy `stepByStepReport` plugin. Default: false.
740+
* `deleteSuccessful`: when `slides=true`, drop slideshow folders for passing tests. Default: true.
741+
* `animateSlides`: when `slides=true`, animate transitions between slides. Default: true.
742+
* `ignoreSteps`: when `slides=true`, RegExps of step names to skip in the slideshow.
750743
751-
```js
752-
"plugins": {
753-
"stepByStepReport": {
754-
"enabled": true
755-
}
756-
}
757-
```
744+
#### Step-by-step slideshow
758745
759-
Possible config options:
746+
`screenshot:on=step;slides=true` writes a per-test `record_<hash>/index.html`
747+
slideshow and a top-level `records.html` index. The output is a self-contained
748+
HTML page with keyboard / dot navigation — no external assets, no JavaScript
749+
frameworks.
760750
761-
* `deleteSuccessful`: do not save screenshots for successfully executed tests. Default: true.
762-
* `animateSlides`: should animation for slides to be used. Default: true.
763-
* `ignoreSteps`: steps to ignore in report. Array of RegExps is expected. Recommended to skip `grab*` and `wait*` steps.
764-
* `fullPageScreenshots`: should full page screenshots be used. Default: false.
765-
* `output`: a directory where reports should be stored. Default: `output`.
766-
* `screenshotsForAllureReport`: If Allure plugin is enabled this plugin attaches each saved screenshot to allure report. Default: false.
767-
* \`disableScreenshotOnFail : Disables the capturing of screeshots after the failed step. Default: true.
751+
> The legacy `screenshotOnFail` plugin remains as a deprecated alias. The legacy
752+
> `stepByStepReport` plugin has been replaced by `screenshot:slides=true`.
768753
769754
### Parameters
770755
771-
* `config` **any**&#x20;
756+
* `config` &#x20;
772757
773758
## stepTimeout
774759

0 commit comments

Comments
 (0)