Koskamo

Writing and organizing tests

Document v1 · published by Koskamo editorial · updated 2026-10-04

Original source

Tests are defined with the test function and assertions with expect, both imported from vitest; it is an alias of test and behaves identically, so teams can pick whichever reads better. Group related tests with describe into named suites — nesting is supported, but keep it shallow because deeply nested tests are harder to read, and a flat list is often enough for simple modules. By default Vitest discovers any file containing .test. or .spec. in its name (the patterns */.test.{ts,js,mjs,cjs,tsx,jsx} and */.spec.{ts,js,mjs,cjs,tsx,jsx}), searching all subdirectories, so tests can live co-located with the source or in a dedicated directory; the include and exclude config options customize discovery. TypeScript works out of the box through Vite's on-the-fly transform with no extra compiler to install, but Vitest does not type-check during the test run — run tsc or vitest typecheck separately when full type checking is needed. Scope: Vitest. Reviewed October 4, 2026.

Source and provenance

Original source
vitest.dev
Published on Koskamo by
Koskamo editorial
Citation version
Document v1
Reuse
Original summaries; linked sources retain their own terms.

The original source supplies the underlying information. Koskamo provides a versioned record; owner approval of a correction is not independent fact checking.