Testing guide

Vitest Guide

Write focused tests that detect meaningful mistakes in your JavaScript and TypeScript.

Web DevelopmentFree accessFoundations first

Where This Fits

Begin with a pure function such as resource filtering or sorting. Write expected results for ordinary, empty and invalid inputs before looking at the implementation. A useful test expresses a behavior someone relies on rather than repeating each line of code.

When fixing a bug, first create a small test that fails for the reported case. Confirm that the failure has the right cause, make the repair and run the affected checks. Resist adding broad mocks that remove the behavior you intended to examine.

Before You Start

  • JavaScript functions and modules
  • A prepared package-based project

What to Focus On

  • Assertions and test cases
  • Async test behavior
  • Reproducing regressions

Put It into Practice

Test a resource filter against an empty query, mixed-case text and a category with no results. Introduce a deliberate bug, watch the relevant test fail, then fix it.

Check Your Understanding

  • Explain why each case matters
  • Observe a meaningful failure
  • Avoid tests tied to irrelevant implementation details

Access and Limits

The guide and tooling are free. Check current runtime requirements. Passing unit tests does not demonstrate a successful complete browser journey.

Using It Offline

Install the runner and dependencies first; local test execution can then work offline.

Check the official source

Follow the learning path
HACKTRONIAN_CLI // COMMAND PALETTE
QUICK_EXEC: