[英]Configuration could not be found in project when running ng test
I have just upgraded to Angular 6 but now our Jenkins build is failing. 我刚刚升级到Angular 6,但是现在我们的Jenkins构建失败了。
It is running this command: 它正在运行以下命令:
ng test -c karma.conf.cli.js
But the error is: 但是错误是:
Configuration 'karma.conf.cli.js' could not be found in project 'projectname'
在项目“ projectname”中找不到配置“ karma.conf.cli.js”
However, the file in question exists in the root of the project. 但是,相关文件存在于项目的根目录中。 This command was running fine on Angular 5. Any ideas?
该命令在Angular 5上运行良好。 Thanks
谢谢
FYI I can reproduce the error by running the same command on the build server. 仅供参考,我可以通过在生成服务器上运行相同的命令来重现该错误。 We have also just upgraded Node.js to v8.11.2 (latest LTS)
我们还刚刚将Node.js升级到v8.11.2(最新的LTS)
I tried many and the one worked for me is as below. 我尝试了很多,为我工作的一个如下。 In your
angular.json
file add configuration section under test below. 在您的
angular.json
文件中,添加下面正在测试的配置部分。
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
....
},
"configurations": { // this will hold a different configuration
"jenkins": {
"karmaConfig": "./karma.conf.ci.js"
}
}
},
And then while running the test use this configuration with --configuration jenkins
options. 然后在运行测试时,将此配置与
--configuration jenkins
选项一起使用。 So the final command will be 所以最后的命令是
ng test --configuration jenkins
It will pick karma.conf.ci.js
as configuration file as it set in the configuration section in angular cli configuration file and run unit test using that configuration file. 它将选择
karma.conf.ci.js
作为在angular cli配置文件的配置部分中设置的配置文件,并使用该配置文件运行单元测试。
I had the same issue in Jenkins after Angular 6 and I solved by replacing: 在Angular 6之后,我在詹金斯(Jenkins)遇到了同样的问题,我通过替换解决了:
ng test --single-run --browsers ChromeHeadless -cc
with: 与:
ng test --watch=false --browsers ChromeHeadless --code-coverage
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.