Skip to Content
MeowKit

Writing Tests

Write unit tests test-first with --tdd, generate Playwright E2E tests, and audit coverage.

This playbook adds test coverage in three ways: unit tests written first, E2E tests generated from a spec, and a coverage audit of a diff.

Best for: Improving coverage, TDD practice Time estimate: 10 to 30 minutes Skills used: mk:testing, mk:qa-manual (E2E), mk:review (coverage audit) Agents involved: tester, developer

Is TDD on?

TDD is opt-in, through --tdd or MEOWKIT_TDD=1. With it on, failing tests must exist before implementation. Without it, tests are recommended and you may write them before, alongside or after the code.

Unit tests, test-first (--tdd)

Step 1: The tester writes failing tests

/mk:cook add input validation to user registration --tdd

The tester writes tests that define the behavior, before the developer touches the implementation:

test('rejects email without @ symbol', () => {
  expect(validateEmail('invalid')).toBe(false);
});

test('rejects password shorter than 8 characters', () => {
  expect(validatePassword('short')).toBe(false);
});

They fail because the validation functions do not exist yet.

Step 2: The developer makes them pass

The developer writes the least code that turns the tests green.

Step 3: Refactor

Tester and developer refine the code, and the tests stay green after each change.

E2E tests (Playwright)

Step 1: Generate from a spec

/mk:qa-manual tasks/plans/260327-checkout/plan.md --generate

mk:qa-manual navigates the app like a human tester, records the interactions as Playwright TypeScript and detects whether the project uses data-testid or data-cy. It writes a feature folder:

checkoutFlowSelectors.ts
checkoutFlowAssertions.ts
checkoutFlowIntercepts.ts
checkout-flow.spec.ts

Selectors, assertions and API mocks live in common/, and each spec file has one test.describe block.

Step 2: Check the selectors

Each getByTestId() selector is checked against the source with grep. A selector that is not found gets a warning comment and a fallback locator.

Step 3: Run the tests

npx playwright test tests/e2e/checkout-flow/

Coverage audit

mk:review includes a test coverage step (Step 4.75). It:

  1. Traces the code paths the diff changes.
  2. Maps user flows and error states to tests.
  3. Lists the paths that have no test.
  4. Generates tests for the gaps through the review's fix-first flow.

Next

QA Testing covers manual QA with structured reports.

On this page