Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: string //# sourceMappingURL= breaking tests #1595

Closed
zanona opened this issue Nov 19, 2017 · 1 comment
Closed

fix: string //# sourceMappingURL= breaking tests #1595

zanona opened this issue Nov 19, 2017 · 1 comment

Comments

@zanona
Copy link

zanona commented Nov 19, 2017

Description

Apparently, there's a bug on AVA when used with nyc for testing where files containing a string with the initial part of a sourcemap instruction, i.e: //# sourceMappingURL=, will fail to generate code coverage as well as being tested.

For bug reports, please provide as much relevant info as possible.

Test Source

index.js

function someFn(src) {
  const ref = `//# sourceMappingURL=${src}`;
  console.log(ref);
}
module.exports = someFn;

test/index.js

const {test} = require('ava'),
      someFn = require('../');

test.todo('some fn with hardcoded the sourcemap string');

Error Message & Stack Trace

$ nyc ava -v

Transformation error for /Users/zanona/Desktop/ava-sourcemaps-fail/index.js ; return original code
An error occurred while trying to read the map file at /Users/zanona/Desktop/ava-sourcemaps-fail/${src}\n`;
Error: ENOENT: no such file or directory, open '/Users/zanona/Desktop/ava-sourcemaps-fail/${src}\n`;'
  - some fn with hardcoded the sourcemap string

  0 tests passed
  1 test todo

----------|----------|----------|----------|----------|----------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
----------|----------|----------|----------|----------|----------------|
All files |  Unknown |  Unknown |  Unknown |  Unknown |                |
----------|----------|----------|----------|----------|----------------|
✨  Done in 1.56s.

Command-Line Arguments

Copy your npm build scripts or the ava command used:

nyc ava

Relevant Links

Environment

Tell us which operating system you are using, as well as which versions of Node.js, npm, and AVA. Run the following to get it quickly:

node -e "var os=require('os');console.log('Node.js ' + process.version + '\n' + os.platform() + ' ' + os.release())"
Node.js v8.7.0
darwin 16.7.0
ava --version > 0.23.0
npm --version > 5.5.1
@sindresorhus
Copy link
Member

I can reproduce this with Mocha too, so this would be better posted on the nyc issue tracker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants