Skip to content
Sarj Code Standards

production-derived-test-cases

Keep an independent membership oracle when production collections supply test cases.

Why

A test table copied from the production allowed or supported collection changes together with that collection, so removed members silently remove their test cases.

Fix

Declare a literal expected membership table, assert the production collection equals it, and drive cases from that table. Keep deliberate dynamic sweeps with an explained local suppression.

Examples

Before — flagged Missing production entries also disappear from these cases
src/roles.test.ts
import { test, expect } from "vitest";
import { SUPPORTED_ROLES } from "./roles.js";
test.each(SUPPORTED_ROLES)("%s", (role) => {
expect(build(role)).toBeDefined();
});
After — preferred An independent assertion notices missing entries
src/roles.test.ts
import { test, expect } from "vitest";
import { SUPPORTED_ROLES } from "./roles.js";
test("membership", () => {
expect(SUPPORTED_ROLES).toEqual(["reader", "writer"]);
});
test.each(SUPPORTED_ROLES)("%s", (role) => {
expect(build(role)).toBeDefined();
});