Skip to content

Commit b7284ba

Browse files
DavertMikclaude
andcommitted
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>
1 parent a14f976 commit b7284ba

22 files changed

Lines changed: 797 additions & 440 deletions

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 stepByStepReport # 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: 15 additions & 12 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` and `pauseOn` plugins still work as deprecated aliases.
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

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+
| `pauseOn` | `pause` | Use `on=fail|test|step|file|url` instead |
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: 51 additions & 43 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 `pauseOn` and `pauseOnFail`
601+
plugins. 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)
617-
618-
### Parameters
603+
```js
604+
plugins: {
605+
pause: {
606+
enabled: false,
607+
on: 'fail',
608+
}
609+
}
610+
```
619611
620-
* `config` (optional, default `{}`)
612+
#### `on=` modes
621613
622-
## pauseOnFail
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=...`
623619
624-
Automatically launches [interactive pause][5] when a test fails.
620+
CLI examples:
625621
626-
Useful for debugging flaky tests on local environment.
627-
Add this plugin to config file:
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/*
628627
629-
```js
630-
plugins: {
631-
pauseOnFail: {},
632-
}
633-
```
628+
> The legacy `pauseOn` and `pauseOnFail` plugins remain as deprecated aliases
629+
> that translate to the new syntax and emit a deprecation warning.
634630
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,31 +700,44 @@ 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
719+
#### `on=` modes
720+
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=...`
726+
727+
CLI examples:
728+
729+
npx codeceptjs run -p screenshot
730+
npx codeceptjs run -p screenshot:on=step
731+
npx codeceptjs run -p screenshot:on=file:path=tests/login_test.js
732+
npx codeceptjs run -p screenshot:on=url:pattern=/users/*
733+
728734
Possible config options:
729735
730736
* `uniqueScreenshotNames`: use unique names for screenshot. Default: false.
731737
* `fullPageScreenshots`: make full page screenshots. Default: false.
732738
739+
> The legacy `screenshotOnFail` plugin remains as a deprecated alias.
740+
733741
### Parameters
734742
735743
* `config` &#x20;

docs/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ Please note, that you shouldn't use a real credit card number here. Good news, y
153153
Run the test with next command:
154154

155155
```
156-
npx codeceptjs run --debug -p pauseOnFail
156+
npx codeceptjs run --debug -p pause
157157
```
158158

159159
What are special options here?
160160

161161
* `--debug` flag is used to output additional information to the console, such as the details of each step in the test, the values of variables, and the results of test assertions. This can help you to identify and fix any issues in your tests.
162-
* `-p pauseOnFail` option is also used to keep the browser opened even if a test fails. It will help us to identify to which point test was executed and what can be improved.
162+
* `-p pause` option is also used to keep the browser opened even if a test fails (default `on=fail`). It will help us to identify to which point test was executed and what can be improved.
163163

164164
Add more test steps if needed, update locators, and notify business owners that all that purchases are made by you so your collegues won't call you in the night asking when you want to get a coffee cup 😀 Also the good idea is to run tests on staging website, to not interfere with business process.
165165

lib/config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ const defaultConfig = {
1515
hooks: [],
1616
gherkin: {},
1717
plugins: {
18-
screenshotOnFail: {
19-
enabled: true, // will be disabled by default in 2.0
18+
screenshot: {
19+
enabled: true,
20+
on: 'fail',
2021
},
2122
},
2223
stepTimeout: 0,

0 commit comments

Comments
 (0)