简体   繁体   中英

Getting a 404 on angular2/testing

I am getting a 404 on angular2/testing as soon as i insert this line into my spec file.

import {
    iit,
    it,
    inject,
    injectAsync,
    beforeEachProviders,
    fakeAsync,
    tick
} from 'angular2/testing';

This is my code inside body tag in user-tests.html

  <script src="node_modules/systemjs/dist/system.src.js"></script>
  <script src="node_modules/angular2/bundles/angular2.dev.js"></script>
  <script src="node_modules/angular2/bundles/http.dev.js"></script>
  <script src="node_modules/angular2/bundles/router.dev.js"></script>
  <script>
      System.config({
          packages: {
              'app': {defaultExtension: 'js'}
          }
      });
      System.import('app/components/user.spec')
              .then(window.onload)
              .catch(console.error.bind(console));
  </script>

Is there any other packages to install to enable testing in angular 2 ? I have installed Jamsine-core per angular2 docs.

npm install jasmine-core --save-dev --save-exact

Thanks !

When using SystemJS (as per docs), you need to add the bundles seperately. This is necessary for every module : http, router and testing.

In your case you need to add testing.dev.js bundle.

<script src="node_modules/angular2/bundles/angular2-polyfills.src.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/http.dev.js"></script>
<script src="node_modules/angular2/bundles/router.dev.js"></script>
<script src="node_modules/angular2/bundles/testing.dev.js"></script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM