SAP Spartacus单元测试里Component实例的创建细节
生活随笔
收集整理的這篇文章主要介紹了
SAP Spartacus单元测试里Component实例的创建细节
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
啟動命令:ng test storefrontlib
單元測試?yán)?#xff0c;使用TestBed創(chuàng)建Component實例的源代碼:
首先在Chrome開發(fā)者工具里找到單元測試用例的實現(xiàn)源代碼:
在_karma_webpack/src目錄下:
Component實例在單元測試用例里的創(chuàng)建方式:
type就是Component的構(gòu)造函數(shù):
從type里獲得Component definition:
根據(jù)Component definition拿到Component factory:
再使用Component factory創(chuàng)建實例:
在實例創(chuàng)建內(nèi)部,依次創(chuàng)建Tview和LView:
RenderView:
創(chuàng)建好的Component instance:
要獲取更多Jerry的原創(chuàng)文章,請關(guān)注公眾號"汪子熙":
總結(jié)
以上是生活随笔為你收集整理的SAP Spartacus单元测试里Component实例的创建细节的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 299元!天猫精灵IN糖3 Pro智能音
- 下一篇: 在Visual Studio Code里