与Karma的Angular2:web服务器404

时间:2016-11-05 21:02:28

标签: javascript angular karma-runner karma-jasmine systemjs

我设法配置了业力,成功进行了虚拟测试。但是,当我尝试实现真正的测试时,事情变得复杂了:

关于我的配置:测试文件(规范)和ts文件位于app文件夹中。另一方面,js个文件和js.map文件位于dist文件夹中。

这是我的业力配置文件:

... 

   files: [
      // System.js for module loading
      'node_modules/systemjs/dist/system.src.js',

      // Polyfills
      'node_modules/core-js/client/shim.js',
      'node_modules/reflect-metadata/Reflect.js',

      // zone.js
      'node_modules/zone.js/dist/zone.js',
      'node_modules/zone.js/dist/long-stack-trace-zone.js',
      'node_modules/zone.js/dist/proxy.js',
      'node_modules/zone.js/dist/sync-test.js',
      'node_modules/zone.js/dist/jasmine-patch.js',
      'node_modules/zone.js/dist/async-test.js',
      'node_modules/zone.js/dist/fake-async-test.js',

      // RxJs
      { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
      { pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },

      // Paths loaded via module imports:
      // Angular itself
      { pattern: 'node_modules/@angular/**/*.js', included: false, watched: false },
      { pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false },

      { pattern: 'systemjs.config.js', included: false, watched: false },
      'karma-test-shim.js',

      // transpiled application & spec code paths loaded via module imports
      { pattern: 'dist/**/*.js', included: false, watched: true },    

      // Asset (HTML & CSS) paths loaded via Angular's component compiler
      // (these paths need to be rewritten, see proxies section)
      { pattern: 'app/**/*.html', included: false, watched: true },
      { pattern: 'app/**/*.css', included: false, watched: true },

      // Paths for debugging with source maps in dev tools
      { pattern: 'app/**/*.ts', included: false, watched: false },
      { pattern: 'dist/**/*.js.map', included: false, watched: false },
  ],

  // Proxied base paths for loading assets
  proxies: {
      // required for component assets fetched by Angular's compiler
      "/app/": "base/app"
  },

  exclude: [],
  preprocessors: {},

它给了我以下错误:

START:
...
05 11 2016 21:42:53.211:WARN [web-server]: 404: /base/dist/js/app/account/account.component
05 11 2016 21:42:53.217:WARN [web-server]: 404: /base/dist/js/app/account/account.service
Chrome 54.0.2840 (Mac OS X 10.12.1) ERROR
  {
    "originalErr": {}
  }

Finished in 0.827 secs / 0 secs

SUMMARY:
✔ 0 tests completed
npm ERR! Test failed.  See above for more details.

我正在使用systemjs。经过一些研究,看起来我的conf(以及我为业力提供文件的方式)出了问题。我尝试过匹配angular2-starter存储库,但我找不到类似于我的项目配置。

Github上提供了其他配置文件(分支功能/测试):

感谢您的帮助!

0 个答案:

没有答案