WebTest AI v2 beta

@asserthive/[email protected] is published under npm's beta tag. Use the documented exact version for this beta; the latest tag may point to an older beta.

Writing specs

A suite is a Markdown file with YAML or JSON frontmatter and one top-level heading per test. Executable JavaScript frontmatter is rejected. Write either a goal with success conditions or exact steps with expected results.

Goal tests

---
suite: documentation smoke
baseUrl: https://example.com
tags: [smoke]
---

# Read the homepage

## Goal
Open the homepage and verify that it explains this example domain.

## Success
- Text: Example Domain
- URL: example.com

Goal execution requires a configured navigator profile. The agent chooses one action from a fresh observation at a time; the runtime independently checks the immutable success conditions. Exact, unique labels resolve locally with no selector call; Jev, OpenAI Decisions, or a profile selector can select ambiguous elements and none replaces the navigator. See Markdown goals and getting started.

Supported success conditions are Text:, Not text:, URL:, and Visual:. Text means normalized visible text. URL conditions use literal substring matching, not glob expressions. Pair negative checks with a positive observable result. Visual: homepage compares a reviewed baseline using exact image bytes; see baseline review.

Do not mix Goal/Success execution with Steps or hooks. Use approved Data keys for private input values; keep secrets in environment variables. A passing result proves the written acceptance conditions, not every unstated business rule.

Recorder authority and evidence

The recorder defaults to Goal/Success authoring. The human-owned goal and observable success criteria are the contract; browser actions captured while demonstrating the flow are evidence, not an automatically approved journey. Goal Markdown therefore omits recorded Steps/Expected.

Recorder artifacts apply secret-field heuristics and configured redaction patterns to known sensitive values. They are not guaranteed to contain only safe data: ordinary form input, UI labels and text, URLs, and inventory fingerprints may remain. Treat every recorder artifact as sensitive and review it before sharing or committing it.

The recorder accepts exactly Text:, Not text:, URL:, and Visual: success prefixes. Visible text entered after an interactive recording becomes Text: automatically; provide explicit --success flags for negative-text and visual criteria. Goals and success conditions are persisted as spec content, so never put secrets in them.

Use webtest-ai record --url <url> --exact only when the recorded action sequence itself should become a Steps/Expected contract. Exact mode does not synthesize a Goal. It is also required for --emit-starter and --starter, and cannot be combined with --goal or --success. Optional --smart cleanup applies only to exact mode; it is skipped during goal authoring so it cannot rewrite approved criteria. Exact-mode smart cleanup sends sanitized normalized events, including ordinary non-secret values and potentially sensitive UI text, to the configured model endpoint. It can change Steps/Expected and can supply generated tags when explicit tags are absent; deterministic output is the fallback.

Exact steps

Use this form to verify installation or exercise a deterministic journey without navigator inference:

---
suite: homepage smoke
baseUrl: https://example.com
---

# Read the homepage

## Steps
1. Open "/"

## Expected
1. Assert text "Example Domain"
1. Assert url "example.com"

Supported bounded instructions include:

Exact unique visible names resolve locally. Ambiguous targets require configured selection and may be inconclusive. End the functional steps with an explicit text, URL, or visual check. Unsupported instructions are rejected before browser execution. Screenshot capture alone is not an assertion.

Authoring and validating either recorder format requires no navigator or selector credential. Running a generated Goal contract later does require a configured navigator unless a fixture or external agent supplies the action decisions. Jev and OpenAI Decisions are optional element selectors, not journey planners.

Engine boundaries

The bounded engine is the default. Goal agents can explicitly switch between observed frames and pages. Legacy scripted frame/popup commands, semantic Assert outcome, healing, browser traces, and journey recording are not translated into bounded contracts. See limits and authentication before migrating complex flows. The reference describes both engines; the migration guide explains the distinction.