1. Define an evaluation
An evaluation inspects a rendered build and returns structured evidence using defineEvaluator and check. Add an optional comparison field to catch gradual drift before an expectation fails outright.
import { check, defineEvaluator } from "plank/sdk";
import { z } from "zod";
export const controlHeight = defineEvaluator({
id: "acme.control-height",
version: "1.0.0",
description: "Buttons meet the project minimum height.",
parameters: z.object({
selector: z.string().default("main button"),
minimum: z.number().positive().default(44),
}),
async evaluate({ page, parameters }) {
const heights: number[] = [];
for (const el of await page.locator(parameters.selector).all()) {
if (!(await el.isVisible())) continue;
const box = await el.boundingBox();
if (box) heights.push(box.height);
}
const shortest = Math.min(...heights);
return [
check({
id: "minimum-height",
title: "Minimum button height",
status: !heights.length
? "not-tested"
: shortest >= parameters.minimum
? "pass"
: "fail",
observations: { heights, shortest, minimum: parameters.minimum },
comparison: {
kind: "numeric",
measure: "shortest",
better: "higher",
tolerance: { absolute: 1 },
},
}),
];
},
});2. Bundle into a standard
Combine custom evaluations with ready-made checks using defineSuite so every consuming product can adopt your standard in one line.
import { defineSuite } from "plank/sdk";
import { controlHeight } from "./control-height";
export const baseline = defineSuite({
id: "acme.baseline",
version: "1.0.0",
evaluators: [
{ use: controlHeight, parameters: { selector: "main button" } },
{ use: "layoutBounds", parameters: { selectors: ["main"] } },
],
});3. Verify with fixtures
Attach a healthy build and an intentionally broken build with defineDetector so Plank proves your evaluation catches the regression and marks it fixed when reversed.
import { defineDetector } from "plank/sdk";
export const controlSize = defineDetector({
id: "acme.control-size",
healthy: "fixtures/healthy",
faulty: "fixtures/faulty",
expected: {
"short-button": ["acme.control-height/home/mobile/minimum-height"],
},
config: {
scenarios: [{ id: "home", path: "/", readySelector: "main" }],
variants: [{ id: "mobile", viewport: { width: 360, height: 780 } }],
evaluators: [{ suite: "acme.baseline" }],
gate: { mode: "regressions" },
},
});4. Ship beside your design system
Publish your Plank evals alongside your other design system packages so consuming teams inherit both the building blocks and the expectations that keep them intact.
@acme/tokensVisual vocabulary shared across themes and surfaces.
@acme/componentsConceptual vocabulary product teams build with.
@acme/evalsExecutable expectations that preserve design intent.