4

I'm having issues to pass my tests with 100% coverage. Istanbul say that exports defaults Component else path not taken.

Because of that, I see in my generated html of istanbul that my tests are not completely at 100%. Mostly in the Statements and Branches tab.

I'm using:

  • React: 15.4.0
  • Jest: 17.0.2
  • Webpack: 1.12.11

Any idea?

enter image description here enter image description here

Albert Olivé Corbella
  • 4,061
  • 7
  • 48
  • 66

1 Answers1

3

The problem was in the jest configuration, we were using a preprocessor in order to resolve some imports:

In the package json we had this:

"transform": {
  "^.+\\.js$": "<rootDir>/cfg/preprocessor.js"
},

This file contained this:

const babelJest = require('babel-jest');
require('babel-register');
const webpackAlias = require('jest-webpack-alias');

module.exports = {
  process: function (src, filename) {
    if (filename.indexOf('node_modules') === -1) {
      src = babelJest.process(src, filename);
      src = webpackAlias.process(src, filename);
    }
    return src;
  }
};

We updated to Jest v20 and also use the module resolver from Jest, in our package.json we added:

"moduleDirectories": [
  "node_modules",
  "src"
],

and removed the transform config from the package.json and the preprocessor.js file.

Jose Paredes
  • 3,882
  • 3
  • 26
  • 50