jeudi 7 décembre 2017

Mocha, nyc code coverage - only testing files are covered

I wrote some tests which are placed in folder test.

enter image description here

Problem: Code coverage with nyc shows me only CC for tested files. Want: All files in src to be shown in CC with precentage, even if they are not tested yet.

My package json and scripts:

"scripts": {
    "start": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js",
    "test": "mocha --compilers js:babel-core/register --require ./test/testing_helper.js ./test/**/*.js",
    "test:watch": "npm run test -- --watch",
    "code:coverage": "nyc npm run test"
  },
  "author": "",
  "license": "",
  "devDependencies": {
    "babel-core": "^6.2.1",
    "babel-loader": "^6.2.0",
    "babel-preset-es2015": "^6.1.18",
    "babel-preset-react": "^6.1.18",
    "chai": "^3.5.0",
    "chai-jquery": "^2.0.0",
    "expect": "^21.2.1",
    "jquery": "^2.2.1",
    "jsdom": "^8.1.0",
    "mocha": "^2.4.5",
    "nyc": "^11.3.0",
    "react-addons-test-utils": "^0.14.7",
    "webpack": "^1.12.9",
    "webpack-dev-server": "^1.14.0"
  },
  "dependencies": {
    "babel-preset-stage-1": "^6.1.18",
    "lodash": "^3.10.1",
    "react": "^0.14.3",
    "react-dom": "^0.14.3",
    "react-redux": "4.3.0",
    "react-router": "^2.0.1",
    "redux": "^3.0.4",
    "redux-devtools-extension": "^2.13.2"
  }

testing_helper.js has many imports for example. jsdom, so whenever I try to make a script with config for nyc includes: testing_helper.js it always says:

unexpected import token -> and reference to jsdom.

Thanks for any help.

Aucun commentaire:

Enregistrer un commentaire