Unit test

From stefvw93/weft · View interactive version

Unit test is an AI agent skill from the GitHub repository stefvw93/weft. Step 4 of the Weft TDD workflow. Use after /type-tests: writes co-located *.test.ts unit tests against the mocked surface, covering every acceptance criterion, error path, and edge case, then runs them and confirms they FAIL (red phase) before handing off to /implement.

How to use this skill

Skill file

/unit-test: Unit tests + red phase (TDD step 4)

Write the feature's unit tests against the mock surface, then prove they fail before any implementation exists.

When to run

Procedure

  1. Read the spec. Tests are written against the acceptance criteria in the co-located specs.md and the mocked API surface. Nothing else.
  1. Write co-located tests (feature.ts → feature.test.ts). __tests__/ directories are allowed for compound/integration tests and shared fixtures/helpers.
  1. Naming: describe for grouping, it/test for cases. Test case names must match or reference acceptance criteria from specs.md. A reviewer should be able to trace every criterion to a test by name.
  1. Coverage requirements (all mandatory):
  1. Effect testing: use Effect testing utilities for Effect code (e.g. Effect.runPromise/test clock/TestContext as appropriate). Follow repo idioms: pipe(effect, ...), specific imports, no import * as X.
  1. Red phase (mandatory):

1. Run vp run test (never bare vp test: the pack rule).

2. Confirm every new test fails. declare mocks have no runtime implementation, so failures are expected; a passing new test is vacuous (asserting nothing, or not exercising the surface). Fix the test.

3. Confirm the tests fail for the right reason (missing implementation), not for compile errors or broken imports.

4. Report the red run result to the user (counts of new failing tests) before handoff.

  1. Hand off. Next step is /implement.

Rules

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.