Angular Jasmine 里一些常用概念学习笔记 - describe, it, beforeEach的用法
生活随笔
收集整理的這篇文章主要介紹了
Angular Jasmine 里一些常用概念学习笔记 - describe, it, beforeEach的用法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
describe: 定義一個test spec group,用來包裹多個specs,也稱為suite:
describe的第二個參數是一個函數,待測試的spec,即測試邏輯,就寫在該函數里。
/*** Create a group of specs (often called a suite).** Calls to `describe` can be nested within other calls to compose your suite as a tree.* @name describe* @since 1.3.0* @function* @global* @param {String} description Textual description of the group* @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites and specs*/先執行describe,再執行beforeEach:
然后執行describe內層嵌套的describe:
這里能看出,describe定義的單個spec,其函數會立即執行:
it函數定義了一個test spec,里面必須包含expectation等測試元素。這里的it不是某個概念的縮寫,而只是一個代詞。
然后執行beforeEach,這是一個異步調用。從調用棧很難能夠分辨出這個beforeEach具體是被誰調用的:
StoreModule.forRoot返回一個組裝好的NgModule結構:
StoreModule.forFeature: 接受的輸入參數為字符串feature和其他module export的getReducers:
store實例通過TestBed.inject注入好之后,在其私有字段_value里,立即能看到里面處于initial狀態的state:
此時從依賴注入器injector里可以直接拿到record了,奇怪:
更多Jerry的原創文章,盡在:“汪子熙”:
總結
以上是生活随笔為你收集整理的Angular Jasmine 里一些常用概念学习笔记 - describe, it, beforeEach的用法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: a1673是ipad几代(苹果A1673
- 下一篇: NgRx使用CreateSelector