Do you want to request a _feature_ or report a _bug_?
Feature
What is the current behavior?
In #5117, #3458 was partially reverted. This is a tracking issue for its reactivation.
If the current behavior is a bug, please provide the steps to reproduce and
either a repl.it demo through https://repl.it/languages/jest or a minimal
repository on GitHub that we can yarn install and yarn test.
N/A
What is the expected behavior?
Make the skipped test in #5117 pass.
Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.
N/A
I don't understand properly what's going on here.
The reason we attempt to read from the sourcemap, is that the test file is added to sourceMapInfo here: https://github.com/facebook/jest/blob/d1845116ebe818e6d945d50ad4857752758970ee/packages/jest-runtime/src/index.js#L440-L447
But when we try to read the file, it's not there:
https://github.com/facebook/jest/blob/d1845116ebe818e6d945d50ad4857752758970ee/packages/jest-cli/src/reporters/coverage_reporter.js#L63
It might be that we just have to add the source map information we write to disk to the _sourceMapStore instance.
Make sure to test that we support #5151 as well when this is fixed.
I'd like to contribute if possible.
PR very much welcome! I won't personally work on this for some time, but happy to review code :)
Cool! I'll give it a shot!
TLDR
mapCoverage boolean at this lineLonger version
Here in the getSourceMapInfo() function, It is taking sourceMaps written into jest's cache folder.
https://github.com/facebook/jest/blob/4f8f6fba35c1cedfb2ce3cb622831c188b221af5/packages/jest-runtime/src/index.js#L440-L447
Here's a sample of what the object this._sourceMapRegistry looks like, all the values end with .map looking for a sourcemap file
{
'/home/aftab/work/code/eoc-ui/src/components/reusable-components/feedback/FeedBack.phnx': '/tmp/jest_rs/jest-transform-cache-f634946ae80171f59c1ddb40b765ffcb-c8daf9fb18de3edbc88a4eda9bec586e/d4/FeedBack_d4992420ed5d74d7f3a0cddeea3ba313.map',
'/home/aftab/work/code/eoc-ui/src/components/reusable-components/feedback/TextToMarkdown.phnx': '/tmp/jest_rs/jest-transform-cache-f634946ae80171f59c1ddb40b765ffcb-c8daf9fb18de3edbc88a4eda9bec586e/12/TextToMarkdown_12d9a7499ca565056659ef0951ca7515.map'
}
From there I went to script_transformer.js transformSource() function.
https://github.com/facebook/jest/blob/4f8f6fba35c1cedfb2ce3cb622831c188b221af5/packages/jest-runtime/src/script_transformer.js#L194-L280
In the snippet that I posted above, the inlineSourceMaps are never read, since mapCoverage defaults to false.
if block where the .map file is supposed to be written, the transformed.map won't be defined. Hence the .map file won't be written into cache.getSourceMapInfo() is called, it returns an empty object.mapCoverage boolean in the place where we read the inlineSourceMapsShould be fixed in #5177