我正在使用Angular 6项目:
运行ng test --code-coverage
时遇到错误。但是在运行ng test
和ng serve
和ng build
时,它工作正常。我试图找到解决此问题的方法。
但我无法解决此问题。您能解决这个问题吗?
详细错误:
ng test --code-coverage
WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.module.rules[14].include should be one of these:
RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? } | [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
-> One or multiple rule conditions
Details:
* configuration.module.rules[14].include should be an instance of RegExp
* configuration.module.rules[14].include: The provided value "" is not an absolute path!
* configuration.module.rules[14].include should be an instance of function
* configuration.module.rules[14].include should be an array:
[RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
* configuration.module.rules[14].include should be an object.
* configuration.module.rules[14].include should be an array:
[RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
at webpack (D:\LTCProjects\AccessandWorkflow\UI\Dev\WorkFlow\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\webpack.js:31:9)
at init (D:\LTCProjects\AccessandWorkflow\UI\Dev\WorkFlow\node_modules\@angular-devkit\build-angular\src\angular-cli-files\plugins\packages\angular_devkit\build_angular\src\angular-cli-files\plugins\karma.ts:153:16)
at Array.invoke (D:\LTCProjects\AccessandWorkflow\UI\Dev\WorkFlow\node_modules\di\lib\injector.js:75:15)
at Injector.get (D:\LTCProjects\AccessandWorkflow\UI\Dev\WorkFlow\node_modules\di\lib\injector.js:48:43)
at config.frameworks.forEach (D:\LTCProjects\AccessandWorkflow\UI\Dev\WorkFlow\node_modules\karma\lib\server.js:154:61)
at Array.forEach (<anonymous>)
at Server._start (D:\LTCProjects\AccessandWorkflow\UI\Dev\WorkFlow\node_modules\karma\lib\server.js:154:23)
at Injector.invoke (D:\LTCProjects\AccessandWorkflow\UI\Dev\WorkFlow\node_modules\di\lib\injector.js:75:15)
at Promise.all.then.then (D:\LTCProjects\AccessandWorkflow\UI\Dev\WorkFlow\node_modules\karma\lib\server.js:127:24)
at tryCatcher (D:\LTCProjects\AccessandWorkflow\UI\Dev\WorkFlow\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (D:\LTCProjects\AccessandWorkflow\UI\Dev\WorkFlow\node_modules\bluebird\js\release\promise.js:512:31)
at Promise._settlePromise (D:\LTCProjects\AccessandWorkflow\UI\Dev\WorkFlow\node_modules\bluebird\js\release\promise.js:569:18)
at Promise._settlePromise0 (D:\LTCProjects\AccessandWorkflow\UI\Dev\WorkFlow\node_modules\bluebird\js\release\promise.js:614:10)
at Promise._settlePromises (D:\LTCProjects\AccessandWorkflow\UI\Dev\WorkFlow\node_modules\bluebird\js\release\promise.js:694:18)
at _drainQueueStep (D:\LTCProjects\AccessandWorkflow\UI\Dev\WorkFlow\node_modules\bluebird\js\release\async.js:138:12)
at _drainQueue (D:\LTCProjects\AccessandWorkflow\UI\Dev\WorkFlow\node_modules\bluebird\js\release\async.js:131:9)
答案 0 :(得分:0)
您的命令应为
ng test --code-coverage=true
如果您想在每次运行测试套件时创建代码覆盖率报告,则可以在CLI配置文件angular.json中设置以下选项:
"test":{
"options":{
"codeCoverage": true
}
}
通过查看错误的方式进行更新
configuration.module.rules[14].include: The provided value "" is not an absolute path!
尝试查看具有路径的任何配置