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
{
"context": "The agent must configure Jest for a new TypeScript Node.js project from scratch, including the jest.config.ts file, package.json script entries, and a basic jest.setup.ts file. The configuration should match the project's src-based directory layout.",
"type": "weighted_checklist",
"checklist": [
{
"name": "ts-jest preset",
"description": "The jest.config.ts file specifies preset: 'ts-jest' to enable TypeScript compilation for Jest.",
"max_score": 12
},
{
"name": "node testEnvironment",
"description": "The jest.config.ts file specifies testEnvironment: 'node'.",
"max_score": 10
},
{
"name": "roots points to src",
"description": "The jest.config.ts file sets roots to ['<rootDir>/src'] so Jest only looks for tests inside the src directory.",
"max_score": 10
},
{
"name": "testMatch for .test.ts files",
"description": "The jest.config.ts includes a testMatch pattern covering **/__tests__/**/*.test.ts and/or **/*.test.ts files.",
"max_score": 10
},
{
"name": "collectCoverageFrom set correctly",
"description": "The jest.config.ts includes collectCoverageFrom: ['src/**/*.ts', '!src/**/*.d.ts'] to include source files and exclude type declaration files.",
"max_score": 10
},
{
"name": "test script in package.json",
"description": "package.json includes a 'test' script running 'jest'.",
"max_score": 8
},
{
"name": "test:watch script in package.json",
"description": "package.json includes a 'test:watch' script running 'jest --watch'.",
"max_score": 8
},
{
"name": "test:coverage script in package.json",
"description": "package.json includes a 'test:coverage' script running 'jest --coverage'.",
"max_score": 8
},
{
"name": "jest.config.ts uses export default",
"description": "The jest.config.ts uses TypeScript ES module syntax (export default {...}) rather than module.exports.",
"max_score": 8
},
{
"name": "setupFilesAfterFramework referenced",
"description": "The jest.config.ts references a setup file (e.g., setupFilesAfterFramework or setupFilesAfterEnv pointing to ./jest.setup.ts).",
"max_score": 8
},
{
"name": "ts-jest and jest devDependencies",
"description": "package.json lists jest, ts-jest, and @types/jest as devDependencies.",
"max_score": 6
},
{
"name": "jest.setup.ts file created",
"description": "A jest.setup.ts file is created in the project root, even if it is minimal or empty, matching the path referenced in jest.config.ts.",
"max_score": 2
}
]
}