derive-test-shape-from-name
Given a clear test name, produce given/when/then scaffolding and an assertion structure. Use after derive-test-name-from-behavior to write the actual test body.
SKILL.mdplugin/skills/derive-test-shape-from-name/SKILL.md
GitHubDerive a test shape from a name
Given a test name like should reject empty username with a ValidationError, produce a Vitest test body with explicit Given/When/Then sections.
Template
it("should <observable behavior>", () => {
// Given: <setup, no assertions>
const input = ...;
// When: <invoke the SUT>
const result = ...;
// Then: <assertions>
expect(result).toBe(...);
});
Rules
- Given sets up state but never asserts.
- When invokes exactly one method or computes one value.
- Then asserts on the result of When. If you have to compute another value to assert on, the test is doing too much.
- Prefer concrete inputs over fixtures.
expect(validate(""))beatsexpect(validate(emptyInput))for readability.
Reusable outside TDD
Used in red phase to scaffold a failing test. Also used by code-review skills to suggest restructuring overly-complex existing tests.