{"record":{"id":"e5a82c83539c64f8","repo":"vuejs/vue-cli","slug":"cannot-resolve-ts-jest-module-typescript-preset","errorCode":null,"errorMessage":"Cannot resolve \"ts-jest\" module. Typescript preset requires \"ts-jest\" to be installed.","messagePattern":"Cannot resolve \"ts-jest\" module\\. Typescript preset requires \"ts-jest\" to be installed\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@vue/cli-plugin-unit-jest/presets/typescript/jest-preset.js","lineNumber":8,"sourceCode":"const deepmerge = require('deepmerge')\nconst defaultPreset = require('../default/jest-preset')\n\nlet tsJest = null\ntry {\n  tsJest = require.resolve('ts-jest')\n} catch (e) {\n  throw new Error('Cannot resolve \"ts-jest\" module. Typescript preset requires \"ts-jest\" to be installed.')\n}\n\nmodule.exports = deepmerge(\n  defaultPreset,\n  {\n    moduleFileExtensions: ['ts', 'tsx'],\n    transform: {\n      '^.+\\\\.tsx?$': tsJest\n    }\n  }\n)\n","sourceCodeStart":1,"sourceCodeEnd":20,"githubUrl":"https://github.com/vuejs/vue-cli/blob/7eb93c169c7520935252e2473387f923ef80d856/packages/@vue/cli-plugin-unit-jest/presets/typescript/jest-preset.js#L1-L20","documentation":"The typescript jest preset extends the default preset and needs `ts-jest` to transform `.ts`/`.tsx` files. It resolves `ts-jest` via require.resolve and throws if the module is absent, because the transform entry would otherwise point at nothing.","triggerScenarios":"Pointing Jest's `preset` at `@vue/cli-plugin-unit-jest/presets/typescript/jest-preset` (or the no-type-check variant) without having `ts-jest` installed.","commonSituations":"TypeScript project set up for Jest with ts-jest missing from devDependencies; ts-jest removed during dependency pruning; version skew between ts-jest and the installed Jest.","solutions":["Install ts-jest: `npm i -D ts-jest`.","Make sure the ts-jest major is compatible with your Jest major (check ts-jest's peer deps).","Verify the preset path string is correct in jest config."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const pkg = require('./package.json')\nif (!(pkg.devDependencies || {}).tsJest && !(pkg.devDependencies || {})['ts-jest']) {\n  console.warn('Typescript jest preset needs ts-jest: run npm i -D ts-jest')\n}","typeGuard":null,"tryCatchPattern":"try { require.resolve('ts-jest') } catch { /* install ts-jest, then re-run jest */ }","preventionTips":["Whenever you select the typescript/no-type-check preset, also add ts-jest.","Match ts-jest's peer-supported Jest major."],"tags":["jest","typescript","unit-test","dependency"],"backgroundTag":null,"analyzedSha":"7eb93c169c7520935252e2473387f923ef80d856","analyzedAt":"2026-08-13T10:13:37.803Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}