我写了一些放在文件夹测试中的测试。
问题:使用nyc的代码覆盖率仅显示测试文件的CC。 想要:src中的所有文件都会显示在CC中,并且还没有经过测试。
我的包json和脚本:
"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,所以每当我尝试 使用config for nyc创建一个脚本包括:testing_helper.js它总是说:
意外导入令牌 - >并提到jsdom。
感谢您的帮助。
答案 0 :(得分:0)
像这样使用 nyc configuration file(来自 here):
{
"all": true,
"include": [
"src/**/*.js"
],
"exclude": [
"**/*.spec.js"
]
}