跳到正文
cccskills
免费在 GitHub 公开

visual-testing

Create Playwright tests that capture table appearance and compare screenshots with reference images using reg-suit. The skill covers checking each state before capture, adding demo routes, and choosing themes, browsers, and framework variants to test.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

Use when writing Playwright visual regression tests or adding a demo route for one - covers the decision rule (what earns a capture, and that a visual spec is in addition to a Playwright assertion), the custom tablePage fixture, the screenshot workflow, reg-suit comparison, and the demo routes in examples/next/visual-tests/

集成工具Playwright
查看安装方法

适用场景

  • Checking table appearance after UI changes
  • Adding screenshot tests for a new feature
  • Comparing appearance across themes and browsers
  • Preparing a dedicated demo route for visual tests

包含的文件(1)

  • SKILL.md9.1 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Visual Regression Testing with Playwright

Visual tests live in visual-tests/ (Playwright + TypeScript); reg-suit compares screenshots against golden records. Two workflows: (a) add a visual test for an existing demo route, (b) add a new /<feature>-demo route to the js demo in examples/next/visual-tests/js/demo/ (the creating-visual-test-examples skill) and write the test for it. examples/next/docs/ is the documentation examples tree and the visual suite does not serve it.

Decision rule

A screenshot proves pixels only. Capture one screenshot per distinct visual state, assert that state first, and keep the DOM and API facts (focus, selection, data, "the menu opened") as Playwright assertions in tests/e2e – a visual spec is in addition to, never instead of them. The canonical paragraph, the measured numbers, and why a new feature gets its own demo route (and its wrapper-coverage cost) are visual-tests/AGENTS.md → Decision rule. Read it before writing the spec.

Custom fixture: tablePage

Import the custom runner. visualTest registers a spec; a bare test( is a lint error:

import { visualTest, expect } from '../../../src/test-runner';

The tablePage fixture (visual-tests/src/test-runner.ts) navigates to the demo page, waits for the table, disables CSS animations and transitions, and before every capture waits out the scrollbar-clearance band and clears a stray native text selection. So an element capture is a clipped tablePage.screenshot().

Test naming

First argument is __filename; the runner builds the title from the path. File names are kebab-case and describe the visual state (apply-active-class-name-nested-header.spec.ts).

Screenshot workflow

Reach a visual state, assert it, capture it once. A second capture is a second visual state.

import { visualTest, expect } from '../../../src/test-runner';
import { helpers } from '../../../src/helpers';
import { selectCell } from '../../../src/page-helpers';

/**
 * Checks that the focused cell renders its current-cell highlight. Owned by DEV-<number>.
 */
visualTest(__filename, {
  themes: ['main', 'main-dark'],
  browsers: ['chromium'],
  wrappers: [],
}, async({ tablePage }) => {
  const cell = await selectCell(0, 2);

  // One visual state: the focused cell. Assert it before the capture; a screenshot on the line
  // after `click()` records whichever half of the transition the runner reached.
  await cell.click();
  await expect(cell).toHaveClass(/current/);
  await tablePage.screenshot({ path: helpers.screenshotPath() });
});

Every test call carries a docblock that says what its capture proves and names the owning ticket: a ClickUp ID in the DEV-, PRO- or SU- space, or a GitHub issue of four or more digits as #12345. Both halves are lint errors when missing (jsdoc/require-jsdoc, jsdoc/require-description, jsdoc/match-description); DEV-<number> above is a placeholder the lint rejects, so a copy fails until it names a real owner. A capture on the statement straight after a click, key press, or other pointer/keyboard action is a lint error at the capture.

Use helpers.screenshotPath() for path: it generates the deterministic file names (test file path, browser, framework, screenshot index) that the path-based comparison matches on.

The visualTest() declaration names the variants the spec renders on; the golden set is the sum of every spec's declaration intersected with the tier. Start from the default shown above (two themes, one browser, no wrapper): two goldens per capture, against five for specs written before the declaration.

  • Add CLASSIC to themes when the spec is about the bare delivery path (the core inlines the main theme stylesheet).
  • Add a horizon theme when the pixels judged are theme tokens rather than geometry.
  • Add a wrapper only with a wrappersReason saying what the wrapper render proves that the js render does not; each wrapper is one more golden per capture.
  • Use themes: ['main'] alone only for a look check whose behavior a functional test asserts on every theme: name that tests/e2e spec (or the Jasmine spec under handsontable/src) in the docblock, in backticks; the declaration sweep checks the file exists.
  • Write one declaration key per line as the example does: on a single line the default is 121 characters, one over the package's max-len.

visual-tests/AGENTS.md → Variant declaration has the axes and the two invariants.

Test organization

  • visual-tests/tests/js-only/: vanilla JS demo only, usually on its own /<feature>-demo route.
  • visual-tests/tests/multi-frameworks/: JS, React, Angular, and Vue demos. They photograph the shared / grid and never navigate.
  • visual-tests/tests/cross-browser/: Chromium, Firefox, and WebKit.

The directory decides which Playwright config runs the spec; the declaration decides which variants it renders inside that config. wrappers: [] keeps a spec off the wrapper baselines, a non-empty wrappers list needs a wrappersReason, and browsers names more than chromium only under cross-browser/. visualTest() emits the skip from the declaration; scope a spec through it (a test.skip() in a spec is a lint error).

Navigating to custom pages

For a demo route other than /, use the goto fixture:

/**
 * Checks that the my-feature demo renders its grid. Owned by DEV-<number>.
 */
visualTest(__filename, {
  themes: ['main', 'main-dark'],
  browsers: ['chromium'],
  wrappers: [],
}, async({ goto, tablePage }) => {
  await goto(
    helpers.setBaseUrl('/my-feature-demo').getFullUrl()
  );
  await expect(tablePage.locator(helpers.selectors.mainTable)).toBeVisible();
  await tablePage.screenshot({ path: helpers.screenshotPath() });
});

A route exists on the js demo only, so a spec that navigates is js-only by construction (wrapper trade-off: decision rule).

Helpers

  • visual-tests/src/helpers.ts: screenshotPath(), selectors, findCell(), cssPath(), setBaseUrl() / getFullUrl().
  • visual-tests/src/page-helpers.ts: selectCell(), openEditor(), openContextMenu(), createSelection(), openHeaderDropdownMenu(), filterByValue(), filterByCondition(), scrollTableToTheBottom(), and more. Capture through tablePage.screenshot({ path: helpers.screenshotPath() }), the one capture form.

Running tests

Scripts: visual-tests/package.json. Configs: visual-tests/playwright.config.ts (default), visual-tests/playwright-cross-browser.config.ts.

What CI renders depends on the tier (VISUAL_TIERS in visual-tests/src/config.mjs; reasoning and numbers in visual-tests/AGENTS.md, Tiers):

  • A pull request renders the pr tier: vanilla JS specs on Chromium with the main and main-dark themes, plus a wrapper only when that wrapper's own wrappers/<pkg>/ tree changed.
  • Horizon, the classic delivery path, Firefox, and WebKit are rendered by the develop seed (visual-seed.yml) after a merge and become the golden records; when the merge changed any of them, the seed comments the list on the merged pull request. The wrappers are rendered for real only by the weekday nightly (visual-nightly.yml; the seed copies the js render into their goldens), which goes red on any difference from the seed outside visual-tests/visual-quarantine.json. A theme-only regression shows in the seed's comment, not as a red nightly.
  • A pull request that touches visual-tests/** or examples/next/visual-tests/** renders everything (the full tier).
  • Locally, VISUAL_TIER=pr npm run build && VISUAL_TIER=pr npm run test (from visual-tests/) renders what a pull request renders and skips the wrapper installs; pass the same VISUAL_TIER=pr to npm run compare. A bare npm run test on a feature branch renders everything. Visual specs run outside git and agent hooks; .ai/LOCAL-ENFORCEMENT.md has the enforcement map.

Demo routes

A new feature gets its own /<feature>-demo route on the js demo's Navigo router (examples/next/visual-tests/js/demo/src/index.js) backed by a src/demos/<feature>/ module (structure: creating-visual-test-examples skill). The shared / grid stays unchanged: every spec that photographs it re-captures on every variant, and its config must stay identical across all four framework demos.

Common mistakes

  • A page helper call between an action and the capture silences the capture lint whether or not the helper asserts, so check that it does: 25 of the 48 exported helpers in src/page-helpers.ts call a pointer or keyboard action and no expect() or wait (2026-09-23). The Determinism section of visual-tests/AGENTS.md lists the shapes that have flaked.
  • Assert the state first with toBeFocused(), toBeVisible(), toBeHidden(), or toHaveClass().
  • JS-only tests belong in js-only/, multi-framework tests in multi-frameworks/.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Develop and modify the Handsontable Angular wrapper with guidance on component lifecycle, settings updates, and NgZone, which controls change detection. It also covers standalone examples, global configuration, and the build and test workflow.

中文简介正在准备中。当前显示英语简介。

  • Fix settings updates in the Angular wrapper
  • Review change detection around grid operations
  • Update examples to standalone components
handsontable/handsontable2.2万2026年10月19日 更新

Open local or public web pages in BrowserStack Live for checks on real mobile devices or desktop browsers. The skill prepares temporary access to a local server, launches the requested session, and shares its dashboard link.

中文简介正在准备中。当前显示英语简介。

  • Check a local page on an Android device
  • Open a page in Safari on an iPhone or iPad
  • Inspect behavior in a specific desktop browser
handsontable/handsontable2.2万2026年10月19日 更新

Prepare user-facing changelog entries for source code changes. The skill determines whether an entry is needed, classifies the change, writes a clear title, and uses the project CLI to create a JSON file tied to the pull request.

中文简介正在准备中。当前显示英语简介。

  • Add a changelog entry for a bug fix
  • Classify a new feature or behavior change
  • Explain a breaking change and its replacement
handsontable/handsontable2.2万2026年10月19日 更新

Explore relationships between functions and files using a prebuilt code graph, a map of code dependencies. Trace bugs, inspect callers and execution paths, and assess the impact of refactoring or proposed changes.

中文简介正在准备中。当前显示英语简介。

  • Explore callers and dependencies in unfamiliar code
  • Trace a bug across multiple files
  • Assess the impact of renaming or removing code
handsontable/handsontable2.2万2026年10月19日 更新

Work with Handsontable row and column positions by distinguishing source data, displayed order, and rendered cells. It guides index conversion and helps investigate misplaced data when sorting, filtering, hiding, or moving rows and columns.

中文简介正在准备中。当前显示英语简介。

  • Investigating misplaced rows or columns
  • Converting between source and displayed indexes
  • Combining filters with manual column movement
handsontable/handsontable2.2万2026年10月19日 更新

Create Handsontable documentation examples for JavaScript, TypeScript, React, Angular, and Vue. The skill explains source files, generated JavaScript, required imports and license settings, embedding examples in guides, and checking that each framework version displays correctly.

中文简介正在准备中。当前显示英语简介。

  • Adding a code example to a feature guide
  • Preparing examples for multiple frameworks
  • Generating JavaScript examples from TypeScript
handsontable/handsontable2.2万2026年10月19日 更新

查看 handsontable 的全部技能

报告此技能的问题