You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently using Ava and Instanbul's nyc to run tests compiled to typescript. The tests are compiled with tsc and sourcemaps enabled, then I run Ava with the compiled JavaScript.
If I run without nyc (ava build/tests), Ava behaves perfectly. The output of a failing test looks like this:
The sourcemap converts the filename to typescript and the line numbers and source files match the Typescript source code.
However, if I run with nyc (nyc ava build/tests), Ava prints JavaScript filenames, the JS source code, and incorrect line numbers:
file›test/path/to/file.js:43: return(mod&&mod.__esModule) ? mod : {"default": mod};4: };5: Object.defineProperty(exports,"__esModule",{value: true});
In both cases, nyc uses the correct line numbers from the source map, so it seems the issue is in the handoff between nyc and Ava.
I have no configuration for Ava as I'm not using it to compile the TS files and the guide doesn't have any other instructions, but I've installed source-map-support. I've tried setting "compileEnhancements": false and require: ["source-map-support/register"], but they make no difference.
It works without nyc (see the second and third paragraphs of my first comment). So the problem could definitely be entirely with nyc. However, since nyc read the source map correctly and then Ava running within nyc didn't, I figured the issue was with both of them.
If you think it would be more suitable, I could also create an issue on the nyc repo. Or do that and close the one here.
Whoops I did more digging and realized this is a duplicate of #1604 (which is without using typescript but the same concept), which is related to istanbuljs/nyc#619. Sorry for wasting your time 😞.
I'm currently using Ava and Instanbul's nyc to run tests compiled to typescript. The tests are compiled with
tsc
and sourcemaps enabled, then I run Ava with the compiled JavaScript.If I run without nyc (
ava build/tests
), Ava behaves perfectly. The output of a failing test looks like this:The sourcemap converts the filename to typescript and the line numbers and source files match the Typescript source code.
However, if I run with nyc (
nyc ava build/tests
), Ava prints JavaScript filenames, the JS source code, and incorrect line numbers:In both cases, nyc uses the correct line numbers from the source map, so it seems the issue is in the handoff between nyc and Ava.
I have no configuration for Ava as I'm not using it to compile the TS files and the guide doesn't have any other instructions, but I've installed
source-map-support
. I've tried setting"compileEnhancements": false
andrequire: ["source-map-support/register"]
, but they make no difference.My nyc config is:
If it would help I can create a minimal reproduction, but I'd first like to check that I'm not missing any configuration options.
Thanks!
The text was updated successfully, but these errors were encountered: