freecoding.school100% FREE · NO SIGNUP
API ArcadeISSUE #20 of 23

testing · jest · vitest · playwright

ApiaVSLegacy Larry
Apia saysTests prove code works: unit (Jest/Vitest), component, and end-to-end (Playwright).

Automated tests catch regressions before users do. Unit tests (Vitest/Jest) check small functions in isolation; integration tests cover modules together; end-to-end (Playwright/Cypress) drive a real browser through user flows. The shape: describe/it with expect(...).toBe(...). Write the test that would have caught the bug.

Power-ups you unlock

Legacy Larry attacks — common mistakes

Boss battleWrite a tiny unit test (in your head) for an add function, including an edge case.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>import { test, expect } from 'vitest';
import { add } from './math.js';

test('adds numbers', () => {
  expect(add(2, 3)).toBe(5);
  expect(add(-1, 1)).toBe(0); // edge case
});</pre></body></html>
▶ Open the interactive comic issue
‹ Linting · Eslint · PrettierPerformance · Profiling · Devtools ›