Jest testing patterns — test structure, mocking, async testing, snapshot
99
99%
Does it follow best practices?
Impact
99%
1.26xAverage score across 6 eval scenarios
Passed
No known issues
The platform team has scaffolded a new Node.js microservice written in TypeScript. The project compiles with tsc and all source code lives under the src/ directory. Until now the team has been doing ad-hoc manual testing, but with the service heading toward its first production release they need a proper automated test setup.
Your job is to wire up Jest so the team can run, watch, and measure coverage of their tests with three simple commands. The project uses TypeScript throughout — there should be no need to compile files manually before running tests.
Produce the following files:
jest.config.ts — the Jest configuration filejest.setup.ts — a minimal global setup file (can be empty or include a comment)package.json — updated (or created) package.json that includes the necessary devDependencies and test scriptsThe configuration should assume all source and test files live under src/.
tsconfig.json{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"rootDir": "src",
"outDir": "dist",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
},
"include": ["src"]
}