nyc: I can't get sourcemaps to work with nyc, babel and mocha
Here is an example of what I am trying to do https://github.com/pghalliday/nyc-babel-mocha-sourcemaps
If you checkout the project and run
npm install
npm test
Then you get the following output
17:53 $ npm test
> nyc-babel-mocha-sourcemaps@1.0.0 test /Users/pghalliday/projects/github/pghalliday/nyc-babel-mocha-sourcemaps
> nyc mocha
test
1) should pass
0 passing (15ms)
1 failing
1) test should pass:
Error: what line number?
at exports.default (src/index.js:1:1185)
at Context.<anonymous> (test/src/index.js:8:5)
ERROR: Coverage for lines (50%) does not meet global threshold (100%)
ERROR: Coverage for statements (50%) does not meet global threshold (100%)
----------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
----------|----------|----------|----------|----------|----------------|
All files | 50 | 100 | 100 | 50 | |
index.js | 50 | 100 | 100 | 50 | 3 |
----------|----------|----------|----------|----------|----------------|
npm ERR! Test failed. See above for more details.
Note that it reports the error as being thrown from src/index.js:1:1185
even though the source file clearly throws on line 2
export default function() {
throw new Error('what line number?');
return 'hello world';
};
I have installed source-map-support
and set nyc to have produce-source-map
and babel to have "sourceMaps": "inline"
and mocha to --require source-map-support/register
(i tried moving that require to nyc too)
Am I missing something or does this just not work. Thanks in advance
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (7 by maintainers)
Ok, but the issue is that source maps don’t work without the plugin when they should.
From the documentation it states that the plugin provides “better” support, specifically for better code highlighting in reports. AFAIK source maps are intended to work without the plugin, so the issue remains.