nyc: filepath bug with nyc & mocha & babel-register@6.11.5

  • nyc@7.0.0
  • mocha@2.4.5
  • babel-register@6.11.5

In .nyc_output json file content, file path should nyc-mocha-chai/src/index.js but nyc-mocha-chai/src/src/index.js.

Demo: https://github.com/d-band/test-boilerplates/tree/master/nyc-mocha-chai

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 3
  • Comments: 17 (2 by maintainers)

Commits related to this issue

Most upvoted comments

babel-register 6.11.6 was just released, which reverted the commit that caused the problem. Sorry guys for the troubles.

Problem solved. There are two ways:

  1. Using babel-register@6.11.6
  2. Using babel-plugin-istanbul

Kudos to @JaKXz , he fixed my setup and everything is working now! Long story short, and like @kripod mentionned, using babel-plugin-istanbul solves the problem.

@edmundito I got it working with the configuration below.

package.json:

{
  "scripts": {
    "test": "cross-env NODE_ENV=test nyc ava --verbose",
    "coverage": "nyc report -r text-lcov -r html > ./coverage.lcov",
  },
  "dependencies": {
    "babel-runtime": "^6.9.2",
  },
  "devDependencies": {
    "ava": "^0.15.2",
    "babel-plugin-istanbul": "^1.0.3",
    "babel-plugin-transform-runtime": "^6.9.0",
    "babel-preset-es2015": "^6.9.0",
    "babel-register": "^6.11.5",
    "cross-env": "^2.0.0",
    "nyc": "^7.1.0-candidate3"
  },
  "ava": {
    "babel": "inherit"
  },
  "nyc": {
    "require": [
      "babel-register"
    ],
    "sourceMap": false,
    "instrument": false
  }
}

.babelrc:

{
  "presets": ["es2015"],
  "plugins": ["transform-runtime"],
  "env": {
    "test": {
      "plugins": ["istanbul"]
    }
  }
}

I tried a few things, but the only thing I can confirm that it works with updating all the way to babel-register 6.9.0 (and having the rest of the babel dependencies up to date).

It has to be one of the 2 changes introduced over the weekend: https://github.com/babel/babel/commits/master/packages/babel-register