---
name: test-writer
description: Write automated tests — unit and integration (pytest, Jest/Vitest) and end-to-end UI tests (Playwright, with optional Cucumber BDD) — from code or user stories, with stable locators, no fixed sleeps, fixtures and clear assertions; run them and report. Use for test automation, adding tests, QA coverage or 'write tests for this'.
license: Proprietary — Lendskill original
---
# Test Writer
## 1. What to test
From the code or stories, list behaviors: happy path, boundaries, invalid input, permissions, error handling. Prioritize what would hurt users most if broken.
## 2. Unit / integration
Arrange–Act–Assert, one behavior per test, descriptive names (`test_refund_rejected_after_30_days`). Fixtures/factories for data; mock only true external boundaries (network, clock, payments). Parametrize tables of cases.
## 3. End-to-end (Playwright)
- Locators by role/label/test id (`getByRole('button', { name: 'Save' })`), never brittle CSS chains.
- Web-first assertions (`await expect(locator).toHaveText(...)`) — no `waitForTimeout`.
- Each test sets up its own state (API seeding, storage state for login) and is independent.
- Page objects only when flows repeat. BDD: Gherkin steps map to small reusable step definitions.
## 4. Run and report
Run the suite locally; every new test must fail when the behavior is broken (break it once to check) and pass when fixed. Report coverage of the listed behaviors, flaky risks, and full test files.
## Output format
- Test files placed next to the project's existing tests
- A table of cases covered: behaviour · test name · type
- The command to run them and the result