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.

Migrating to the bounded engine

This guide covers migration to the published @asserthive/[email protected] beta. In this release, the default runtime is bounded, and the CLI's default driver is cdp. Treat the upgrade as an execution compatibility change and validate existing suites before adopting the new defaults. The package name remains @asserthive/webtest-ai.

Adopt the new path

  1. Choose Goal/Success for agent-directed execution, or retain Steps/Expected for scripted execution. See Markdown goals. A goal needs observable success conditions and a configured agent profile.
  2. Replace Assert outcome with a concrete observable assertion. For example, assert the confirmation text and destination URL required by the acceptance criteria. Semantic verdicts are not release gates in the new runner.
  3. Select CDP and configure Jev, OpenAI Decisions, or a local selector profile. Exact, unique labels resolve locally with no selector call. A separate navigator profile is still required for Goal execution; keep selectors and credentials out of Markdown.
  4. Seed a test tenant and declare approved input values or environment references. Use isolated, resettable data for actions that submit or change application state.
  5. Run a representative smoke set. Compare failure detection, false passes, ambiguity rate, model-call count, cost completeness, and p95 runtime against the previous runner.
  6. Update consumers to accept inconclusive, flaky, schema-v2 reports, nullable costs, and attempt-specific artifacts. Gate on observed results, not a confidence score.

Migrate recorder workflows

The recorder now produces Goal/Success contracts by default. Treat the human-approved goal and success conditions as the authority; the demonstrated clicks, fills, and navigation remain local evidence and are not emitted as Steps/Expected. Existing automation that expects recorded scripted output must opt into exact compatibility mode:

webtest-ai record --url http://127.0.0.1:3000 --exact

Add --emit-starter or --starter <path> only with --exact. Exact output contains recorded Steps/Expected and no synthetic Goal. It cannot be combined with --goal or --success.

For headless or non-interactive goal authoring, pass a nonblank --goal and one or more explicit --success conditions. Interactive authoring can collect success conditions after capture, but every finished goal contract needs at least one. The supported prefixes are exactly Text:, Not text:, URL:, and Visual:. Invalid authoring fails before the browser starts.

When stdin is non-TTY, capture completes after the initial page load; it does not drive or verify a journey. An API caller can drive the page and use stopWhen or stopAfterMs. When stdin is a TTY, --headless still waits for manual terminal stop with an invisible browser, so use headed mode for interactive migration capture.

Goal-mode --smart cleanup is skipped so it cannot rewrite approved criteria. In 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 remains the fallback.

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.

Recording and production-parser/compiler validation are credential-free: they need no Jev account, OpenAI Decisions access, OPENAI_API_KEY, or TYPESAFE_API_KEY. Running the resulting Goal contract later still requires a configured navigator unless actions come from a fixture or external agent. Selectors choose among finite elements; they do not plan the journey.

Keep a suite on the previous engine

{
  "driver": { "name": "playwright" },
  "execution": { "engine": "legacy" }
}

Legacy CDP is also available by choosing driver.name: "cdp". The old runner moved to src/runtime/legacyRunTest.js; the maintained native driver moved from examples into src/runtime/drivers/nativeCdp.js. The example import remains a compatibility export. Existing regression tests explicitly exercise the legacy engine; new tests exercise the default path separately.

Previous behaviorBounded behavior
Generate the entire plan from a goal at run timeExecute an immutable reviewed contract
Repeated broad role/text searches and first matchesObserve, choose a finite reference, revalidate the actual node
Semantic confidence can pass a testExplicit browser assertions own verdicts
Unrecognized Expected prose can be omittedReject the contract
Retry can overwrite artifacts and hide earlier costSeparate attempt folders and aggregate call/cost history
Model costs omittedKnown token cost plus explicit unknowns and optional infrastructure estimates
Planner or healing changes the journeyStop with evidence; propose repairs separately
Broad feature support from the old engineA smaller, explicit grounded action surface

Bounded goals can now choose observed frames and pages explicitly. Legacy scripted frame commands are not automatically translated; migrate their intent into goals and validate against your application. See context and authentication boundaries. Current screenshot settings work; browser traces and journey recording remain legacy features. After hooks run within the original deadline, so external fixture cleanup should also be recoverable by the factory after worker termination.

Configuration and schema changes

The new selector section chooses element selection independently of the required Goal navigator profile. Profile selection uses provider: "profile" plus the profile name; provider: "jev" retains the pinned Jev path, and provider: "openai-decisions" sends text/JSON candidate state to POST https://api.openai.com/v1/decisions using gpt-6-luna and OPENAI_API_KEY by default. That state is redacted according to configured reporting/redaction rules and excludes input values and screenshots, but candidate names, context, and intent are sent and can contain sensitive UI text. Use hosted selection only on pages whose labels and context are approved to leave your environment. Decisions does not plan the journey. Its pricing is unknown unless selector.pricing is configured.

Supported bounds are maxSteps, maxToolCalls, maxModelCalls, and maxCandidates. The last value must be at most 254, reserving one selector option for NONE. Cleanup is allowed one extra lifecycle event beyond the tool limit. Requests are limited to 96 KB. A deadline aborts model transport and closes the browser context; execution does not resume when a late response arrives.

Report schema v2 is additive for existing result fields. cost remains model-only; runCost includes configured elapsed-time infrastructure estimates. Preserve null totals in downstream systems. Do not convert them to zero. Tool counts refer to framework operations, including observation, assertion polls, model requests, and context lifecycle, not individual CDP protocol messages.

Every finite-choice selector response must contain one current offered reference or NONE, confidence, and a probability entry for every offered reference and NONE. Missing, extra, unknown, out-of-range, or inconsistent outputs stop execution, as do refusals, missing credentials, transport errors, and timeouts. The default positive minMargin rejects tied top probabilities; explicitly configuring minMargin: 0 can permit a tied top distribution. The runtime does not fall back to a different selector provider. This differs from the old planner's generated action list.

Quality evidence and visual checkpoints

Bounded HTML and agent JSON reports expose separate accessibility, Web Vitals, and visual results. Each check records its policy, status, reason, measurements, and evidence. Disabled and unavailable checks never appear as passes. A failed journey skips end-of-test accessibility and vitals checks.

Configure checks explicitly:

{
  "execution": { "quality": {
    "a11y": { "mode": "fail", "maxSerious": 0 },
    "vitals": { "mode": "warn", "lcpMaxMs": 2500, "clsMax": 0.1 }
  } },
  "visual": { "mode": "fail", "baselineDir": "visual-baselines", "updateBaselines": false }
}

Modes are off, warn, and fail. Threshold failures in fail mode fail the test; unavailable required evidence makes it inconclusive. Warning mode preserves the functional verdict and records findings. Accessibility uses axe; vitals measure lab LCP and CLS, not INP or field Core Web Vitals compliance.

Add Visual: checkout under a goal's Success section, or Capture visual checkpoint "checkout" in a scripted test. The navigator cannot replace this assertion. Action screenshots alone do not perform visual regression.

Visual checkpoints compare exact image bytes, with separate baseline and actual images and a hash difference record. They do not offer pixel tolerances or heatmaps. Use stable data, fonts, viewport, and browser versions. Baselines are scoped by suite, test, target, browser, and checkpoint name.

Missing baselines are unavailable and are never created automatically. Set visual.updateBaselines: true explicitly to capture candidates. This returns review-required and an inconclusive verdict. Review the images, commit approved baselines, then rerun with updates disabled. Keep baseline updates outside unattended release gates.

The legacy HTML reporter remains active for legacy execution and retains its compatibility coverage. Bounded execution uses the new reporter; both retain the full JSON artifact.