2017-02-12 68 views
0

我在SystemJS + Typescript環境(基本上a plunk應該是Angular 2測試裝備)運行茉莉花測試。Jasmine異步啓動在SystemJS + Typescript環境

茉莉花故意用作全局庫,而不是通過TypeScript import

這導致

不規範發現

有控制檯沒有錯誤,規格只是不運行:

main.ts

describe('test',() => { 
    it('test',() => { 
    console.log('test'); 
    expect(1).toBe(1); 
    }); 
}); 

我認爲這是由於t o事實上,main.ts與SystemJS異步加載,因此Jasmine引導過程應該額外觸發以使其選擇規範。

該手冊描述了什麼是default boot configuration in Jasmine,但它不能很好地解釋如何手動執行引導。

在這種情況下使用SystemJS和全局Jasmine運行測試的方式是什麼?

回答

1

原因是您的規格在jasmine已經嘗試搜索並執行它們之後加載。

爲了克服這個問題後,你的規格是由system.js加載可以再次調用window.onload

<script> 
    System.import('app').then(window.onload).catch(console.error.bind(console)); 
</script> 
+0

感謝。調用事件處理程序直接看起來像一個黑客,但我不明白[htmlReporter變量](https://github.com/jasmine/jasmine/blob/v2.5.2/lib/jasmine-core/boot.js#L140 )否則可能會達到。 – estus