Stage 6 · Lesson 6 of 8
Tests on the core logic
Test the that hold your project's rules, not the file or network code around them. is a common choice for unit tests. Install it with npm install -D vitest, name files like budget.test.js, and write tests such as test("totals a month", () => { expect(monthlyTotal(entries)).toBe(42.5); }).
also ships a built-in runner, node --test with node:test and node:assert, if you want no at all. Cover such as an empty array, one entry and invalid input. Use expect(() => parseAmount("abc")).toThrow() for rejected input, and toBeCloseTo for decimals.
Put the runner in the test script so npm test works. When you find a bug, write the failing test first.
A question to check yourself, an AI practice session and 2 cheat sheet entries come when you add the roadmap to your account. Add it
Resources for this stage
Start with· follow one of these
- GitHub repoFreeProject Based Learning
Community maintained · Beginner
Follow one guided build in your language, then build your own without a guide
- BookFreeEloquent JavaScript
Marijn Haverbeke · Intermediate
Free: the project chapters (a robot, a programming language, a pixel editor) show real structure
Keep handy
Also worth your time
How to present each project: the problem, stack, challenges and results
- Build Your Own XGo deeper
When you want a harder build: a shell, a key-value store or a tiny Git, from scratch