1
我們一直拉着我們的頭髮了幾天,並不能真正似乎得到實際問題的保持。我們想創造一個測試平臺,以提高我們的代碼覆蓋,但事實證明這是預計將不會那麼容易。JSPM和測試平臺和無法解釋的「testing.js」輸出
包括正確的區域文件後,我們發現,通過觀察快速入門的角度,我們需要調用TestBed.initTestEnvironment。只要我們嘗試通過噶運行這個(茉莉花),我們碰上了404
import * as browserTesting from '@angular/platform-browser-dynamic/testing';
TestBed.initTestEnvironment(
browserTesting.BrowserDynamicTestingModule,
browserTesting.platformBrowserDynamicTesting()
);
然而,:
Running "karma:single" (karma) task
Verifying property karma.single exists in config...OK
File: [no files]
Options: background=false, client={}
20 12 2016 13:22:25.757:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
20 12 2016 13:22:25.764:INFO [launcher]: Starting browser Chrome
20 12 2016 13:22:26.439:INFO [Chrome 54.0.2840 (Linux 0.0.0)]: Connected on socket cuixl-0soveFUA_PAAAA with id 58970475
20 12 2016 13:22:26.711:WARN [web-server]: 404: /base/jspm_packages/npm/@angular/[email protected]/bundles/compiler-testing.umd.js/index.js
20 12 2016 13:22:26.713:WARN [web-server]: 404: /base/jspm_packages/npm/@angular/[email protected]/bundles/core-testing.umd.js/index.js
20 12 2016 13:22:26.714:WARN [web-server]: 404: /base/jspm_packages/npm/@angular/[email protected]/bundles/platform-browser-testing.umd.js/index.js
Chrome 54.0.2840 (Linux 0.0.0) ERROR
Error: (SystemJS) XHR error (404 Not Found) loading /home/arend/Documents/Projects/Barco/opspace/barco-opspace/jspm_packages/npm/@angular/[email protected]/bundles/compiler-testing.umd.js/index.js
Error: XHR error (404 Not Found) loading /home/arend/Documents/Projects/Barco/opspace/barco-opspace/jspm_packages/npm/@angular/[email protected]/bundles/compiler-testing.umd.js/index.js
at XMLHttpRequest.wrapFn [as _onreadystatechange] (/home/arend/Documents/Projects/Barco/opspace/barco-opspace/jspm_packages/npm/[email protected]/dist/zone.js:729:25) [<root>]
at Zone.runTask (/home/arend/Documents/Projects/Barco/opspace/barco-opspace/jspm_packages/npm/[email protected]/dist/zone.js:135:41) [<root> => <root>]
at XMLHttpRequest.ZoneTask.invoke (/home/arend/Documents/Projects/Barco/opspace/barco-opspace/jspm_packages/npm/[email protected]/dist/zone.js:285:27) [<root>]
Error loading /home/arend/Documents/Projects/Barco/opspace/barco-opspace/jspm_packages/npm/@angular/[email protected]/bundles/compiler-testing.umd.js/index.js as "./bundles/compiler-testing.umd.js/index" from /home/arend/Documents/Projects/Barco/opspace/barco-opspace/jspm_packages/npm/@angular/[email protected]/testing.js
一個需要的參數,我們進口
看着「jspm_packages/npm/@ angular/compiler @ 2.3.0/testing.js」,我們很快發現它保存了錯誤信息:
module.exports = require('./bundles/compiler-testing.umd.js/index');
,而不是預期:
module.exports = require('./bundles/compiler-testing.umd');
如果我手動更正,這一切完美的作品。所以我問題: 我們如何防止JSPM或產生錯誤testing.js文件的人?
我們的想法是,由於某種原因,熱蒙公司認爲,編譯器testing.umd.js文件是一個文件夾,所以追加/索引它
*我們包括通過配置的角度文件。 JS:*
System.config({
defaultJSExtensions: true,
transpiler: "typescript",
paths: {
"github:*": "jspm_packages/github/*",
"npm:*": "jspm_packages/npm/*"
},
map: {
"@angular/common": "npm:@angular/[email protected]",
"@angular/compiler": "npm:@angular/[email protected]",
"@angular/core": "npm:@angular/[email protected]",
"@angular/core/testing": "npm:@angular/[email protected]/bundles/core-testing.umd.js",
"@angular/forms": "npm:@angular/[email protected]",
"@angular/http": "npm:@angular/[email protected]",
"@angular/http/testing": "npm:@angular/[email protected]/bundles/http-testing.umd.js",
"@angular/platform-browser": "npm:@angular/[email protected]",
"@angular/platform-browser-dynamic": "npm:@angular/[email protected]",
"@angular/platform-browser-dynamic/testing": "npm:@angular/[email protected]/bundles/platform-browser-dynamic-testing.umd.js",
"@angular/router": "npm:@angular/[email protected]",