簡體   English   中英

在angular2 /測試中獲得404

[英]Getting a 404 on angular2/testing

一旦我將此行插入到我的spec文件中,我就會在angular2 /測試中獲得404。

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

這是我在user-tests.html中的body標簽內的代碼

  <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>

是否還有其他軟件包需要安裝才能在角度2中進行測試? 我已經為每個angular2文檔安裝了Jamsine-core。

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

謝謝 !

使用SystemJS時(根據文檔),您需要單獨添加捆綁包。 這對於每個模塊都是必需的:http,路由器和測試。

在您的情況下,您需要添加testing.dev.js包。

<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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM