我写了一些测试,这些测试放在test文件夹中。
问题: 使用nyc进行代码覆盖率测试时,只显示已测试文件的CC。
期望结果: 显示src中所有文件的CC百分比,即使它们尚未被测试。
我的package.json和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有许多导入,例如jsdom,因此每当我尝试使用配置为nyc包括:testing_helper.js的脚本时,它总是会显示:
意外的导入令牌->以及对jsdom的引用。
感谢任何帮助。