You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/debugging.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -107,6 +107,13 @@ After(({ I }) => {
107
107
})
108
108
```
109
109
110
+
### Pause Modes
111
+
112
+
`pause()` adapts to who's driving the test:
113
+
114
+
-**TTY (humans)** — when `process.stdin` is a terminal (running `npx codeceptjs run --debug` yourself), the readline REPL described above opens.
115
+
-**MCP server (agent-driven debug)** — the MCP server registers an in-process pause handler before running tests, so when `pause()` fires inside a `run_test` invocation, control yields back to the agent. The agent drives the REPL through the [`pause` MCP tool](/mcp#pause). The same `I` container the test uses runs the agent's code, so artifacts (URL, ARIA, HTML, screenshot, console, storage) are captured against the live page.
116
+
110
117
## Pause Plugin
111
118
112
119
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`.
The context narrows the search to one region of the page, and the semantic string says what the user actually clicks. This is **more precise than ARIA or CSS alone** because it combines structural scope with human-readable intent.
24
24
25
-
Supported strategies: `css`, `xpath`, `id`, `name`, `role`, `frame`, `shadow`, `pw`. Shadow DOM and React selectors have their own pages — see [Shadow DOM](/shadow) and [React](/react). Playwright-specific locators (`_react`, `_vue`, `data-testid`) use the `pw` strategy: `{ pw: '_react=Button[name="Save"]' }`.
25
+
Supported strategies: `css`, `xpath`, `id`, `name`, `role`, `frame`, `shadow`, `pw`. Shadow DOM and React selectors have their own pages — see [Shadow DOM](/shadow) and [React](/react). Playwright-specific locators use the `pw` strategy: `{ pw: '[data-testid="save"]' }`.
- Pause runs in-process: `run_code` and the test share the same `I` / browser. There's no subprocess, no IPC.
274
+
-`run_test` and `continue` wrap test execution in the same `withSilencedIO` helper that `run_step_by_step` uses, so step output doesn't interleave with the MCP JSON-RPC stream. Stdout/stderr are restored before each tool call returns.
275
+
- TTY behaviour (`npx codeceptjs run --debug` at a terminal) is unchanged — `pause()` opens the readline REPL whenever `process.stdin.isTTY` is true.
276
+
238
277
### run_test
239
278
240
-
Run a specific test by name or file path. Uses subprocess to run tests with isolation.
279
+
Run a specific test by name or file path. Runs in-process so it shares the same `I` / browser as `run_code` and `snapshot`. If the test calls `pause()` — or if `pauseAt` is set and the Nth step completes — this tool returns early and the agent drives the session through `run_code` and `continue`.
241
280
242
281
**Parameters:**
243
282
-`test` (required): Test name or file path
244
283
-`timeout` (optional): Timeout in milliseconds (default: 60000)
245
284
-`config` (optional): Path to codecept.conf.js
285
+
-`pauseAt` (optional): 1-based step index. The test pauses after the Nth step completes. Use this as a programmatic breakpoint without editing the test. Discover step indices via the `list` CLI (`--steps`) or via `run_step_by_step`.
"Call snapshot to capture URL/HTML/ARIA/screenshot/console/storage at this point",
306
+
"Call run_code to inspect or manipulate state (e.g. return await I.grabText(\"h1\"))",
307
+
"Call continue to release the pause and let the test finish"
308
+
]
267
309
}
268
310
```
269
311
270
312
**Features:**
271
313
- Automatically resolves test names to file paths
272
314
- Supports partial test name matching
273
-
- Uses json reporter for structured output
274
-
- Executes in subprocess for isolation
275
-
- Includes stderr for debugging
315
+
- Runs in-process; results assembled from CodeceptJS test events
316
+
- Yields on `pause()` (or `pauseAt`) so the agent can inspect via `run_code` and release with `continue`
276
317
277
318
**Example:**
278
319
```json
@@ -287,57 +328,52 @@ Run a specific test by name or file path. Uses subprocess to run tests with isol
287
328
288
329
### run_step_by_step
289
330
290
-
Run a test step by step with detailed step information including timing and status. Generates AI-friendly trace files.
331
+
Run a test interactively, pausing after every step. Returns a paused payload after the first step completes — the agent then calls `continue` to advance one step at a time, or `run_code` / `snapshot` to inspect state at any pause.
291
332
292
333
**Parameters:**
293
334
-`test` (required): Test name or file path
294
-
-`timeout` (optional): Timeout in milliseconds (default: 60000)
335
+
-`timeout` (optional): per-call timeout in milliseconds (default: 60000)
// → ... and so on, until { "status": "completed", "reporterJson": {...} }
339
371
```
340
372
373
+
For a one-shot breakpoint (pause once at a specific step rather than every step), use `run_test` with `pauseAt: N` instead.
374
+
375
+
For per-step trace artifacts written to disk (HTML / ARIA / screenshot / console / storage per step) without the interactive flow, enable the `aiTrace` plugin.
376
+
341
377
### start_browser
342
378
343
379
Start the browser session (initializes CodeceptJS container).
Copy file name to clipboardExpand all lines: docs/playwright.md
+38-2Lines changed: 38 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -478,11 +478,47 @@ When a test fails and video was enabled a video file is shown under the `artifac
478
478
479
479
Open video and use it to debug a failed test case. Video helps when running tests on CI. Configure your CI system to enable artifacts storage for `output/video` and review videos of failed test case to understand failures.
480
480
481
-
It is recommended to enable [subtitles](https://codecept.io/plugins/#subtitles) plugin which will generate subtitles from steps in `.srt` format. Subtitles file will be saved into after a video file so video player (like VLC) would load them automatically:
481
+
## Screencast
482
+
483
+
For richer evidence than helper-level `video`, enable the [`screencast`](https://codecept.io/plugins/#screencast) plugin. It uses Playwright's `page.screencast` API (Playwright >= 1.59) to record WebM video with optional burned-in action captions and a standalone `.srt` subtitle track.
484
+
485
+
```js
486
+
plugins: {
487
+
screencast: {
488
+
enabled:true,
489
+
on:'fail',
490
+
}
491
+
}
492
+
```
493
+
494
+
`on: 'fail'` (default) deletes the recording when the test passes; `on: 'test'` keeps every test's video.
495
+
496
+
`captions: true` (default) burns `I.click()` / `I.fillField()` annotations into the video via `page.screencast.showActions()`. `subtitles: true` writes a standalone `.srt` file alongside the video — VLC and most players auto-load it.
npx codeceptjs run -p screencast:on=test;captions=false;subtitles=true
516
+
517
+
The recording is attached to the test as `test.artifacts.screencast`; the `.srt` (when enabled) is attached as `test.artifacts.subtitle`.
518
+
519
+
> Enabling helper-level `video: true`**and** the `screencast` plugin produces two independent recordings (one in `output/videos/`, one in `output/screencast/`). Pick one.
520
+
521
+
## Trace
486
522
487
523
If video is not enough to descover why a test failed a [trace](https://playwright.dev/docs/trace-viewer/) can be recorded.
Records WebM video of tests using Playwright's screencast API (Playwright >= 1.59).
706
+
When `captions` is enabled, action annotations are burned into the video; when
707
+
`subtitles` is enabled, a standalone `.srt` file is also produced.
708
+
709
+
```js
710
+
plugins: {
711
+
screencast: {
712
+
enabled:true,
713
+
on:'fail',
714
+
}
715
+
}
716
+
```
717
+
718
+
#### `on=` modes
719
+
720
+
* **fail** — record while running; delete on pass, keep on fail (default)
721
+
* **test** — record and keep every test's video
722
+
723
+
CLI examples:
724
+
725
+
npx codeceptjs run -p screencast
726
+
npx codeceptjs run -p screencast:on=test
727
+
npx codeceptjs run -p screencast:on=test;captions=false;subtitles=true
728
+
729
+
Possible config options:
730
+
731
+
* `captions`: burn-in action overlays via `page.screencast.showActions()`. Default: true.
732
+
* `subtitles`: also write a standalone `.srt` file alongside the video. Default: false.
733
+
* `video`: record a video. With `video=false, subtitles=true`, only the `.srt` is produced (next to `test.artifacts.video` if a helper recorded one). Default: true.
734
+
* `size`: pass-through `{ width, height }` for `screencast.start`.
735
+
* `quality`: pass-through 0–100 for `screencast.start`.
736
+
737
+
> Enabling Playwright's helper-level `video:true` and this plugin together
738
+
> produces two independent recordings. Pick one.
739
+
740
+
### Parameters
741
+
742
+
* `config`  
743
+
703
744
## screenshot
704
745
705
746
Saves screenshots from the browser at points triggered by `on=`. Replaces the
@@ -812,20 +853,6 @@ plugins: {
812
853
813
854
* `config`  
814
855
815
-
## subtitles
816
-
817
-
Automatically captures steps as subtitle, and saves it as an artifact when a video is found for a failed test
0 commit comments