CodePark/ questions / Strategy & the test pyramid
START PRACTICINGPRACTICE
Backend question · Backend testing › Strategy & the test pyramid

Which statement about Jest, Vitest and Node's built-in test runner is correct?

Node's node:test module ships with Node, runs with node --test, and includes mocking helpers such as mock.fn()

"Node's node:test module ships with Node, runs with node --test, and includes mocking helpers such as mock.fn()" is correct. node:test has been stable since Node 20. It gives you these with no extra dependency:
•
test and describe
•
mock.fn() and mock.method()
• timer mocks


The other statements are wrong:

• "Vitest can only test code built with Vite" is false. Vitest is a general-purpose runner, and it works for plain Node code.

• "Jest runs all test files one after another in a single process" is false. By default, Jest runs test files in parallel, in worker processes.