testing-visual

A set of instructions for testing web components by comparing their rendered screenshots with saved reference images in Storybook, a tool for viewing components in isolation.

In plain words
What is it for?
Use it when running visual tests, updating screenshot references, or investigating differences between local results and CI.
Why use it?
It helps developers test only the component they changed and avoid accidentally rewriting unrelated screenshot references. It also explains why shared references must be generated in the same environment as continuous integration (CI).

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/ocean-industries-concept-lab/openbridge-webcomponents/testing-visual
Clone the repo
git clone --depth 1 https://github.com/Ocean-Industries-Concept-Lab/openbridge-webcomponents

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,574 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01574
Opus 5 $0.00000 $0.00787
Sonnet 5 $0.00000 $0.00315
Haiku 4.5 $0.00000 $0.00157

Measured 2d ago against content hash 21bf62195b72, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

testing-visual scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/testing-visual.mdc · 145 lines

How it starts

The opening of the file, as written. The whole thing — 145 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Visual Testing and Storybook Config

Run one component, not the suite

The full snapshot suite is slow and its failures are hard to attribute. Always scope to the component you changed:

npx vitest run --project storybook 'component-name'

Updating baselines — the filter must come BEFORE --update:

npx vitest run --project storybook 'component-name' --update   # correct
npx vitest run --project storybook --update 'component-name'   # WRONG

Written after the flag, the name is consumed as the flag's value and the full suite runs in update mode, silently rewriting unrelated flaky baselines. This is the single most damaging mistake in this area.

Always re-run without --update afterwards to confirm the new baselines are stable.

Baselines are environment-sensitive

__vis__/linux/__baselines__/    committed — what CI compares against
__vis__/linux/__results__/      local output, gitignored
__vis__/darwin/__baselines__/   macOS, NOT committed

Only the Linux baselines ship. Regenerating on macOS produces diffs CI will reject.

Prefer the CI path: comment /update-snapshots on the pull request. The update-snapshots.yml workflow regenerates inside the same Docker image CI uses and pushes the result to the PR branch. Locally, the Docker route is npm run test-storybook:docker — see IMPLEMENTATION_GUIDELINES.md § Docker Testing and ci-and-release.md.

Storybook config

.storybook/ holds main.ts, preview.tsx, manager.ts (sidebar badges for the lifecycle tags), openbridgeTheme.ts, and vitest.setup.ts, which wires the snapshot project.

Two facts that bite:

  • Run npm run analyze before testing a new component's stories. Storybook resolves story args to element properties through custom-elements.json; without it the args silently never reach the element.
  • Lifecycle badges are derived, never hand-written. meta.tags mirrors the class JSDoc — see jsdoc.md. Tooling tags (autodocs, skip-test, !snapshot) and version tags (6.0, 6.1) stay hand-written.

Read the full file on GitHub · 145 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 145 lines · 0 tokens per session scan A 21bf62195b72

Subscribe to this mod's changes

testing-visual is a cursor rule published in the GitHub repository Ocean-Industries-Concept-Lab/openbridge-webcomponents (91 stars, last pushed 3d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 1,574 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.