🐛 Bug Report
The mapRoot setting breaks source map URL generation.
To Reproduce
Steps to reproduce the behavior:
- add
"mapRoot": "./src", to tsconfig.json (any relative path will do),
- TypeScript generated file
sourceMappingURL will be a relative path, not a file name in this case: //# sourceMappingURL=../../src/app/app.component.spec.js.map
- the
updateOutput function expects the path to be just a file name
|
const sourceMapLength = |
|
`${base}.map`.length + (getExtension(normalizedFileName).length - extname(normalizedFileName).length) |
, so the code updated by ts-jest looks like: //sourceMappingURL=../../src/app/data:application/json;charset=utf-8;base64,...,
- the malformed
sourceMappingURL causes Jest to ignore it and to map errors and coverage incorrectly.
Expected behavior
The updateOutput function should expect the path to be a relative path, not always a file name.
Link to repo (highly encouraged)
The issue can be reproduced in any repo by adding the mapRoot setting and either inspecting generated code, or producing any error in the sample repo and observing incorrect line reporting by Jest.
This sample repo may be used: https://github.com/ArtemGovorov/wallaby-2434.
Running npx jest in the repo's root produces wrong error report (lines are not mapped) because of the issue described above:

🐛 Bug Report
The
mapRootsetting breaks source map URL generation.To Reproduce
Steps to reproduce the behavior:
"mapRoot": "./src",totsconfig.json(any relative path will do),sourceMappingURLwill be a relative path, not a file name in this case://# sourceMappingURL=../../src/app/app.component.spec.js.mapupdateOutputfunction expects the path to be just a file namets-jest/src/compiler/instance.ts
Lines 25 to 26 in 5e957c7
ts-jestlooks like://sourceMappingURL=../../src/app/data:application/json;charset=utf-8;base64,...,sourceMappingURLcauses Jest to ignore it and to map errors and coverage incorrectly.Expected behavior
The
updateOutputfunction should expect the path to be a relative path, not always a file name.Link to repo (highly encouraged)
The issue can be reproduced in any repo by adding the
mapRootsetting and either inspecting generated code, or producing any error in the sample repo and observing incorrect line reporting by Jest.This sample repo may be used: https://github.com/ArtemGovorov/wallaby-2434.
Running
npx jestin the repo's root produces wrong error report (lines are not mapped) because of the issue described above: