feat(scenario): split log args into message/data and add debug level
CI / changes (pull_request) Successful in 12s
CI / version (pull_request) Skipped
CI / server (pull_request) Successful in 1m4s
CI / client (pull_request) Successful in 1m33s
CI / image (pull_request) Skipped

- context.log/warn/error and console.* split arguments: strings join
  into message, object/array args are kept out of it and stored as
  the log entry's new data column (JSON), so message stays a stable
  string regardless of an object's shape
- added a debug log level alongside log/warn/error, including
  context.debug() and console.debug() (previously folded into log)
- CSV/Markdown run log export include the data column/block
- LogOutput renders data pretty-printed in a separate block below
  the message, and dims debug entries with a dedicated grey token
  calibrated to the WCAG AA contrast floor
This commit is contained in:
ars9 committed 2026-10-01 14:09:45 +03:00
1 parent 6cba785e2f
commit 1273491eee
13 files changed
+204 -45

No files matched your search

+4 -2
View File
@@ -34,7 +34,7 @@ Available on `context`:
- `context.getCredential(alias)`: payload of the credential assigned to the scenario under `alias` (parsed JSON when the data is JSON; throws if missing)
- `context.getStepOutput(order)`: output of a previous step by absolute order (`1`, `2`, ...) or relative (`-1` = previous step); `null` if there is none
- `context.dumpDom(selector?)`: simplified DOM snapshot of the page (or of one element)
- `context.log(...args)`, `context.warn(...args)`, `context.error(...args)`: run log entries
- `context.log(...args)`, `context.warn(...args)`, `context.error(...args)`, `context.debug(...args)`: run log entries
- `context.assert(() => boolean, description)`: runs the arrow function and requires it to return `true`. Logs `description` (as a `log` entry on success, as an `error` entry on failure or exception), then throws to stop the step if the function returned anything other than `true` or threw
- `context.runSnippet(name, ...args)`: runs stored snippet code with the same context; the snippet receives the extra arguments as `...args`. `name` is the snippet alias for its latest version, or `alias@<version>` (e.g. `login@3`) to pin a specific version. Snippet start/finish/failure is logged
- `context.getScenarioFiles(opts?)`: list files uploaded to the scenario (`limit`, `offset`), including their path on disk
@@ -42,7 +42,7 @@ Available on `context`:
Also in scope:
- `console`: proxied to run logs (`log`, `warn`, `error`, etc.)
- `console`: proxied to run logs (`log`/`info` → `log`, `warn`, `error`, `debug`)
- `expect`: Playwright's `expect` (e.g. `await expect(context.page.locator("h1")).toHaveText("Done")`)
Code is syntax-checked before it runs, and executes in the server process: it's trusted code, not sandboxed.
@@ -56,6 +56,8 @@ Each run log entry (`level`, `message`, `createdAt`) also carries a `context`: w
- `assertion:pass` / `assertion:fail`: `context.assert()`'s own log entry
- `run`: run-level entries not tied to a step (e.g. a scenario timeout, or the Playwright trace upload notice)
`context.log`/`warn`/`error` (and `console.log`/etc.) split their arguments: strings/numbers/booleans are joined into `message`, while object/array arguments are kept out of it and stored as `data` (JSON), so `message` stays a stable string regardless of an object's shape. With one object argument `data` is that object; with more than one, `data` is an array of them. E.g. `context.log("Saved credential as run file:", fileMeta)` logs `message: "Saved credential as run file:"` with `fileMeta` as `data`, shown pretty-printed and separately from the message in the UI.
`GET /scenarios/:id/runs/:runId?q=...` and the exported CSV/Markdown logs (`GET /scenarios/:id/runs/:runId/export`) match `q` against both `message` and `context`.
## Versioning