Screen states, markScreenState, and ExploreChimp
What are screens and states?
- Screen — A distinct page or view in your application (for example Login, Dashboard, Checkout).
- State — A meaningful configuration of that screen (for example empty form, error displayed, cart with items).
Stable screen–state names are how TestChimp attributes UX findings (from ExploreChimp, exploratory agents, and Atlas) to the right place in the product. They should match your project Atlas vocabulary where possible—use list-screen-states / upsert-screen-states (MCP or product) so names stay consistent.
Canonical: markScreenState Playwright fixture
New SmartTests and agent-authored tests should use the markScreenState fixture only—not legacy line comments (see Legacy comment annotations below).
How it works
-
installTestChimpfrom@testchimp/playwright/runtimeis applied to your mergedtestintests/fixtures/index.js(often withmergeTests). That registersmarkScreenStateon the sametestinstance specs import—never importtestfrom@playwright/testin*.spec.*files if you rely on TestChimp runtime behaviour. -
In each UI test, declare the fixture on the callback:
async ({ page, markScreenState }) => { ... }. -
After the UI has settled on a meaningful boundary, call:
await markScreenState('Login', 'Empty form');- First argument — Screen name (Atlas-aligned).
- Second argument — State name; optional — omit for a default state, for example
await markScreenState('Dashboard').
-
Order matters — Data for the interval since the previous
markScreenStateis attributed to that previous checkpoint; screenshot + DOM (+ related signals) attach to the current checkpoint. -
Do not over-mark: skip loading spinners and transient overlays; mark only durable states your team cares to regress against.
Example
import { test, expect } from '../fixtures';
test('checkout happy path', async ({ page, markScreenState }) => {
await page.goto('/cart');
await markScreenState('Cart', 'With items');
await page.getByRole('link', { name: 'Checkout' }).click();
await expect(page.getByRole('heading', { name: 'Checkout' })).toBeVisible();
await markScreenState('Checkout', 'Shipping step');
});
Why this matters for ExploreChimp
ExploreChimp (optional /testchimp test Phase 5, /testchimp evolve, or /testchimp explore) sends checkpointed analytics—DOM, screenshots, console, optional network and metrics—along the same journeys as your SmartTests. Without markScreenState, there is little structure for the pipeline to attribute issues to. See /testchimp explore and the runtime plugin.
Naming: Prefer installTestChimp; installTrueCoverage is a deprecated alias (same implementation) in older repos.
Workflow with Atlas (agents and teams)
When authoring or reviewing UI tests:
list-screen-states— See existing vocabulary before inventing new names.upsert-screen-states— Add new screen–state pairs when the product introduces new surfaces.- Add
await markScreenState(...)immediately after the step that establishes each stable state.
During /testchimp test, this sequence aligns with Phase 4: Validate in the skill workflow.
Legacy comment annotations
Older specs may use line comments after steps:
await page.goto('https://example.com/login');
// @screen: Login @state: Empty form
That format can still be parsed on legacy code, but do not add it to new tests—use the markScreenState fixture so Playwright, TrueCoverage, and ExploreChimp share one code path.
Product note: Some Web IDE flows (for example “Update Script Annotations”) may still talk in terms of comments; prefer migrating those outputs to markScreenState when you touch the file.
Best practices (summary)
- Atlas first — Align names with
list-screen-states/upsert-screen-states. - Mark after stability — Wait for navigation, network idle, or assertions that prove the UI is ready.
- Granularity — Define states at the level you want bugs grouped (for example Cart with out-of-stock item vs a single Cart state) depending on product risk.
- ExploreChimp last — Turn on
EXPLORECHIMP_ENABLEDonly when functional tests and Validate-quality markers are trustworthy, so analytics map to real product states.
For deeper authoring rules used by agents, see the TestChimp skill → references/write-smarttests.md.