When I debug my tests, the breakpoints do not show up in the correct place. They are unbound. Setting a breakpoint in a Typescript file results in the debugger stopping on a completely different line in the corresponding Javascript code. The issue only occurs when executing jest in the debugger. Running the app code (not tests) with the same launch config lets me use breakpoints normally.
I would like to be able to set breakpoints and step through the Typescript file from the VS code debugger when running tests.
Project structure:
.
├── src
│ ├── test
│ | └── example.test.ts
│ | └── jest.config.ts
│ └── example.ts
├── tsconfig.json
VS Code launch.json:
"version": "0.2.0",
"configurations": [
{
"name": "Unit Tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/jest/bin/jest.js",
"--config",
"${workspaceRoot}/build/src/test/jest.config.js",
"--runInBand"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229,
"outFiles": ["${workspaceFolder}/build/**/*.js", "!**/node_modules/**"]
}
]
}
TS Config:
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": ["ES2020"],
"declarationMap": true,
"sourceMap": true,
"composite": true,
"outDir": "build",
"moduleResolution": "node",
"typeRoots": ["node_modules/@types", "types"],
"types": ["node", "jest"],
"esModuleInterop": true
},
"exclude": ["node_modules", "build"]
}
Other info: I am running the tsc command prior to the tests and the /build folder looks ok. It seems as though the source maps are not being found, but I have already checked the .js.map files and they look correct. Notably, the default coverage provider for jest is able to map the coverage back to the .ts file. So, I believe it is a vs code launch configuration issue.
This is a minimal version of the project. I have requirements that limit me to using tsc and then jest, rather than just using ts-jest to JIT transform.
outFilesproperty from thelaunch.jsondoes it work (albeit slowly)?