jest-runner-tsc
raw JSON → 1.6.0 verified Fri May 01 auth: no javascript maintenance
A Jest runner for the TypeScript compiler that allows running type checking as part of the Jest test suite. Version 1.6.0 (latest, 2019) uses transpileModule for faster builds and supports custom tsconfig paths. No significant updates since 2019; library is in maintenance mode. Differentiators: integrates TypeScript compilation directly into Jest's runner pipeline, provides type errors as test failures, and supports project references via tsconfig. Alternatives: ts-jest for combined compilation and testing, or a separate tsc --noEmit step.
Common errors
error TypeError: Jest: Got error running runner: Cannot find module 'jest-runner-tsc' ↓
cause jest-runner-tsc is not installed or not in Jest's module resolution path.
fix
Install jest-runner-tsc as devDependency and ensure Jest can resolve it (check working directory).
error Configuration error: Unknown option 'displayName' ↓
cause Using Jest version < 24 where displayName was not supported.
fix
Remove displayName or upgrade Jest to >=24.
error Cannot find module 'typescript' ↓
cause TypeScript is not installed or not in node_modules.
fix
Install TypeScript: npm install --save-dev typescript
Warnings
gotcha This runner only type-checks files matching testMatch. If your tsconfig includes other files, they won't be checked unless included in testMatch. ↓
fix Ensure your testMatch glob covers all TypeScript files you want to type-check, or use tsconfig's include/files.
deprecated Package has not been updated since 2019. It may not work with newer Jest versions (>=27) due to changes in Jest runner API. ↓
fix Consider using ts-jest with isolatedModules or separate tsc --noEmit step.
gotcha By default, tsconfig.json is resolved relative to the Jest rootDir (usually the project root), but you can override with tsconfigPath option. ↓
fix If your tsconfig is not in rootDir, set 'tsconfigPath' in jest-runner-tsc config.
gotcha The runner uses transpileModule, so it does not output any files. It only reports type errors. ↓
fix Do not expect any compiled output; use a separate build step.
Install
npm install jest-runner-tsc yarn add jest-runner-tsc pnpm add jest-runner-tsc Imports
- jest-runner-tsc wrong
const runner = require('jest-runner-tsc')correctmodule.exports = { runner: 'jest-runner-tsc', ... }
Quickstart
// jest.tsc.config.js
module.exports = {
runner: 'jest-runner-tsc',
displayName: 'tsc',
moduleFileExtensions: ['ts', 'tsx', 'js'],
testMatch: ['<rootDir>/**/*.ts'],
// Optional: specify tsconfig path
// transform: { '^.+\\.tsx?$': 'ts-jest' }, // Not needed
// globalSetup: undefined,
// ... other Jest config
};
// package.json
{
"jest-runner-tsc": {
"tsconfigPath": "./tsconfig.json"
}
}
// Run with: jest -c jest.tsc.config.js