Blog

Node.js test runner: mocking fetch with undici, CORS headers in snapshot tests, and coverage of OPTIONS

Node’s built-in test runner can assert `Response` objects—include Access-Control-* in golden fixtures when testing CORS middleware.

1 min read
nodejstestingcors

Watch mode

File watchers may rerun flaky CORS tests—stabilize order of header assertions.

Concurrency settings can interleave tests—isolate global fetch mocks per test file.

CI matrices

Test across Node LTS versions—undici internals evolve and can change header merging.

Back to blog