我正在尝试为Jenkins中的构建生成代码覆盖率报告- 在本地执行命令
npm run coverage
"scripts": {
"test": "cross-env mocha test -t 5000 --recursive --exit --reporter mochawesome",
"coverage":"nyc --reporter=html --reporter=text ./node_modules/.bin/mocha test -t 5000 --recursive --exit"
},
它将运行测试,然后为我提供代码覆盖率结果
现在,当相同的代码在詹金斯中运行时,出现此错误
/var/lib/jenkins/jobs/api-ci-develop/workspace/back-end/node_modules/path-to-regexp/index.js:63 path =('^'+ path +(strict?'':path [path.length-1] ==='/'?'?':'/?')) ^
TypeError:无法读取未定义的属性“ length” 在pathtoRegexp(/var/lib/jenkins/jobs/api-ci-develop/workspace/back-end/node_modules/path-to-regexp/index.js:63:49) 在新层(/var/lib/jenkins/jobs/api-ci-develop/workspace/back-end/node_modules/express/lib/router/layer.js:45:17)
显然是在使用node_module文件夹做某事,但我不确定如何避免这种情况。我在nyc配置中排除了文件夹和文件
"nyc": {
"branches": 5,
"lines": 25,
"functions": 13,
"statements": 25,
"check-coverage": true,
"exclude": [
"**/services/plaidService.js",
"**/node_modules/**",
"**/node_modules/plaid/lib/PlaidClient.js"
]
},
有什么想法我该怎么做才能避免检查node_modules文件夹?