user636525
user636525

Reputation: 3200

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 !

Upvotes: 1

Views: 956

Answers (1)

Eric Martinez
Eric Martinez

Reputation: 31797

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>

Upvotes: 3

Related Questions