By the end of this lesson your app will have unit tests for every rule in ACCEPTANCE.md, written by the AI, and you will be able to read a pass or fail result: which test, what was expected, what was received.
You need: your project with ACCEPTANCE.md from Lesson 2, a terminal in the project folder, your coding agent · Time: 9 minutes
Vitest is a free test tool for JavaScript and TypeScript projects. It needs Node.js 22.12 or newer, so check your version first (same command on Windows, macOS and Linux):
Terminal · macOS / Linuxnode --versionIf it shows
v22.12or higher (for examplev24.11.0), you are ready. If not, install the current LTS version from nodejs.org, as in Set up your computer.Now let the agent do the setup. Vitest's docs install it with
npm install -D vitest; the agent runs that for you:Prompt · copy it into your AI agentSet up Vitest for unit tests in this project. 1. Run: npm install -D vitest 2. In package.json, add the script "test": "vitest run" (run once and exit, not watch mode). 3. Do not change any app code yet. 4. Run npm test and paste the full output, even if it says no tests were found.
Why?vitest runruns the tests once and stops. Plainvitestkeeps watching for changes, which can leave an agent waiting forever for a command that never ends.
Log in free to read the rest of this lesson
Every lesson is free. A free account unlocks all of them and saves your progress.
Still to come in this lesson:
- Turn each criterion into a test
- Read a passing run
- Read a failing run
- Fix the code, not the test
- Recap