0
我的環境設置非常像官方Angular2快速啓動,有一點不同:代替public/src/app
,我有public/app
。Angular2測試,SystemJS無法加載模塊
當試圖測試Component
與ViewChild
:
@ViewChild('profileModal')
profileModal: ModalComponent;
其在組件裝載下測試爲:
import { ModalComponent } from 'ng2-bs3-modal/ng2-bs3-modal';
npm test
示出了這樣的錯誤:
05 05 2017 17:45:48.218:WARN [web-server]: 404: /base/ng2-bs3-modal/ng2-bs3-modal
[1] Chrome 58.0.3029 (Mac OS X 10.12.2) ERROR
[1] {
[1] "originalErr": {
[1] "__zone_symbol__currentTask": {
[1] "type": "microTask",
[1] "state": "notScheduled",
[1] "source": "Promise.then",
[1] "zone": "<root>",
[1] "cancelFn": null,
[1] "runCount": 0
[1] }
[1] },
[1] "__zone_symbol__currentTask": {
[1] "type": "microTask",
[1] "state": "notScheduled",
[1] "source": "Promise.then",
[1] "zone": "<root>",
[1] "cancelFn": null,
[1] "runCount": 0
[1] }
[1] }
karma.config.js : [消隱爲了簡潔]
module.exports = function(config) {
var appBase = 'app/'; // transpiled app JS and map files
var appSrcBase = appBase; // app source TS files
config.set({
basePath: '.',
proxies: {
'/base/node_modules/': '/base/node_modules/'
},
})
}
我怎麼能告訴karma
從/base/npm_modules/ng2-bs3-modal/ng2-bs3-modal
而不是/base/ng2-bs3-modal/ng2-bs3-modal
加載,因爲它試圖。使用SystemJs
而不是Webpack
。