2017-04-05 76 views
0

我使用Karma + Jasmine來測試我的基於webpack的angular2應用程序。Jasmine + Webpack:供應商茉莉花全球功能

要開發項目,我使用​​作爲角度依賴關係,以保持主文件儘可能小,並減少webpack重新編譯時間。

// Angular 
import '@angular/platform-browser'; 
import '@angular/platform-browser-dynamic'; 
import '@angular/core'; 
import '@angular/common'; 
import '@angular/http'; 
import '@angular/router'; 
import '@angular/forms'; 

// RxJS 
import 'rxjs'; 

import 'zone.js'; 
import 'reflect-metadata'; 

我創建了test.ts其中我導入了所有的測試。我在karma start之前每次重新編譯它。

問題是,最終的test.js不僅包含測試代碼,而且包含整個茉莉花庫。我也想供應它,但找不到正確的供應商導入。

看起來像Jasmine是默認的全局庫,並且我還沒有能夠在dt中找到任何@types/jasmine-core

誰能幫我嗎?

回答

0

好吧,我覺得茉莉花是我需要的供應商的錯誤。像describeit這樣的函數無論如何都會在測試運行中使用,無論它們是否存在於編譯文件中。

我需要在我的情況下,以供應商提供的唯一的事情就是expect,我已經通過在供應商文件中添加

import * as expect from "expect"; 
expect('true').toBe('true'); //doesn't work without it, for some reason 

實現了。