Angular Karma WARN [web-server]:404运行测试时

时间:2016-05-18 17:12:39

标签: angular gulp karma-runner karma-jasmine karma-coverage

我一直试图为angular2,sass和ng2-bootstrap设置一个基础项目,这个项目基于angular2-seed项目,你可以在这里找到整个代码库:https://github.com/omargon/angular-seed-sass-ng2-bootstrap对于dev和prod发布,所有内容都按预期构建。但是每当我尝试运行uni和e2e测试时,我都会遇到以下错误:

START:
18 05 2016 12:49:29.095:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
18 05 2016 12:49:29.100:INFO [launcher]: Starting browser PhantomJS
18 05 2016 12:49:29.112:INFO [launcher]: Starting browser Chrome
18 05 2016 12:49:29.756:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket /#87aZKElcLH5MAZgxAAAA with id 21686761
18 05 2016 12:49:29.910:INFO [Chrome 50.0.2661 (Mac OS X 10.11.5)]: Connected on socket /#tFoYBsOvsGJ0dDEGAAAB with id 7030871
18 05 2016 12:49:31.062:WARN [web-server]: 404: /app/app.component.html
  NameList Service
    ✔ should return the list of names
18 05 2016 12:49:31.160:WARN [web-server]: 404: /app/app.component.html
  App component
    ✖ should build without a problem

Finished in 0.158 secs / 0.136 secs

SUMMARY:
✔ 2 tests completed
✖ 2 tests failed

FAILED TESTS:
  App component
    ✖ should build without a problem
      PhantomJS 2.1.1 (Mac OS X 0.0.0)
      Chrome 50.0.2661 (Mac OS X 10.11.5)
    Failed: Uncaught (in promise): Failed to load app/app.component.html
        at ZoneDelegate.invoke (/Users/omar/Development/public/angular-seed-sass-ng2-bootstrap/node_modules/zone.js/dist/zone.js:323:29)
        at Zone.run (/Users/omar/Development/public/angular-seed-sass-ng2-bootstrap/node_modules/zone.js/dist/zone.js:216:44)
        at /Users/omar/Development/public/angular-seed-sass-ng2-bootstrap/node_modules/zone.js/dist/zone.js:571:58
        at ZoneDelegate.invokeTask (/Users/omar/Development/public/angular-seed-sass-ng2-bootstrap/node_modules/zone.js/dist/zone.js:356:38)
        at Zone.runTask (/Users/omar/Development/public/angular-seed-sass-ng2-bootstrap/node_modules/zone.js/dist/zone.js:256:48)
        at drainMicroTaskQueue (/Users/omar/Development/public/angular-seed-sass-ng2-bootstrap/node_modules/zone.js/dist/zone.js:474:36)
        at F (/Users/omar/Development/public/angular-seed-sass-ng2-bootstrap/node_modules/systemjs/dist/system-polyfills.js:4:7484)
        at H (/Users/omar/Development/public/angular-seed-sass-ng2-bootstrap/node_modules/systemjs/dist/system-polyfills.js:4:7116)
        at q.when (/Users/omar/Development/public/angular-seed-sass-ng2-bootstrap/node_modules/systemjs/dist/system-polyfills.js:4:10790)
        at T.run (/Users/omar/Development/public/angular-seed-sass-ng2-bootstrap/node_modules/systemjs/dist/system-polyfills.js:4:11899)
        at t._drain (/Users/omar/Development/public/angular-seed-sass-ng2-bootstrap/node_modules/systemjs/dist/system-polyfills.js:4:1744)
        at drain (/Users/omar/Development/public/angular-seed-sass-ng2-bootstrap/node_modules/systemjs/dist/system-polyfills.js:4:1398)
        at MutationObserver.e (/Users/omar/Development/public/angular-seed-sass-ng2-bootstrap/node_modules/systemjs/dist/system-polyfills.js:4:3319)

欢迎任何帮助。

1 个答案:

答案 0 :(得分:0)

解决方法是使用以下参数通过gulp-inline-ng2-template管道build.js.test结果:

 {
  useRelativePaths: false,
};