为啥 Angular 8 CircleCI 构建在执行 ng test --watch-false 时失败,业力配置为 singleRun=true?
Posted
技术标签:
【中文标题】为啥 Angular 8 CircleCI 构建在执行 ng test --watch-false 时失败,业力配置为 singleRun=true?【英文标题】:Why Angular 8 CircleCI build fails while executing ng test --watch-false, with karma configured to singleRun=true?为什么 Angular 8 CircleCI 构建在执行 ng test --watch-false 时失败,业力配置为 singleRun=true? 【发布时间】:2020-05-08 06:36:17 【问题描述】:我正在将一个开源项目 WUF 从 Angular@7.2.0 迁移到 @8.2.14;其 CircleCI CI/CD 管道 WUF 在 Angular@7.2.0 上运行良好,现在在尝试执行单元测试时迁移到 Angular@8.2.14 后失败;测试通过然后失败,构建尝试运行多次。
我正在 FM-736-ng8
分支上构建。
CircleCI config.yml 的相关部分是:
- run:
name: Test WUF
command: |
ng test --watch=false --karmaConfig=src/karma.conf.circleci.js
业力配置文件karma.conf.circleci.js 包含一个执行测试并停止的标志,似乎没有效果。同样,在 Angular@7.2.0 上工作得很好,现在在迁移到 Angular@8.2.14 后失败了。
most recent and relevant log 文件 sn-ps 见下文:
开始构建:
0% 编译 10% 构建 0/0 模块 0 活动
第一次单元测试运行结束:块引用
10% building 0/0 modules 0 active 10% building 0/1 modules 1 active multi /root/wuf/node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/es5-polyfills.js/root/wuf/node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/es5-jit-polyfills.js/root/wuf/src/polyfills.ts 10% building 1/1 modules 0 active 10% building 1/1 modules 0 active 10% building 1/2 modules 1 active multi /root/wuf/src/polyfills.ts/root/wuf/node_modules/@angular-devkit/build-angular/src/angular-cli files/models/jit-polyfills.js 10% building 2/2 modules 0 active 10% building 2/2 modules 0 active 10% building 2/3 modules 1 active multi /root/wuf/src/styles.scss/root/wuf/src/assets/dummydata/branding/branding.scss 10% building 3/3 modules 0 active START: 10% building 3/4 modules 1 active /root/wuf/node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/es5-polyfills.js 10% building 4/4 modules 0 active ...
HomeComponent + should create Layout + should have a view component + should have a header component + should have a content component + should have a footer component I18nAngularComponent + should create + should have cardinality paragraph showing 'no wolves' + should have gender paragraph + should have gender paragraph showing 'female.' + should have pluralization paragraph + should have pluralization paragraph showing 'has no wolves.' I18nNgxTranslateComponent + should create + should create Finished in 5.459 secs / 5.426 secs @ 00:50:40 GMT+0000 (Coordinated Universal Time) SUMMARY: + 68 tests completed # 1 test skipped 0% compiling 10% building 0/0 modules 0 active
注意测试如何结束、通过和重新启动。如果你查看日志,你会发现这会重复很多次,直到被 CircleCI 杀死。
预期的行为是单元测试运行一次然后停止!
【问题讨论】:
【参考方案1】:这太尴尬了!我有一个由多个npm packages
和一个展示它们的application
组成的单一回购项目。使用 ng test
运行单元测试时,测试会在运行应用程序测试后停止,而不运行包的测试。
当使用ng test --watch false
运行单元测试时,应用程序测试运行,然后包测试运行;我将包错误解释为应用程序测试错误。
我的错误是查看我正在处理的问题,即应用程序测试,而不是我最初关注的领域。很尴尬,但确实如此。
【讨论】:
以上是关于为啥 Angular 8 CircleCI 构建在执行 ng test --watch-false 时失败,业力配置为 singleRun=true?的主要内容,如果未能解决你的问题,请参考以下文章
apache_conf Angular CLI的CircleCI配置