Needed to TDD a pure algorithm (relatedFor(post, all)) for the site’s
related-posts feature. First instinct was “add Vitest.” Vitest is great
but it adds a nontrivial config surface, and this repo has actively
resisted adding a second test runner alongside Playwright.
Turns out Node 22’s builtin node --test is perfectly fine for this
shape of test, and with --experimental-strip-types it can load
.ts imports directly. Full package.json script:
"test:unit": "node --experimental-strip-types --test 'tests/unit/**/*.test.mjs'"
The test files themselves are .mjs and use node:test + node:assert/strict.
They import .ts source files directly - the strip-types flag handles
the transpilation on the fly. No build step, no Vitest config, no
dependency.
10 test cases, 97ms to run, zero new packages. If your test surface is pure functions, this is enough.