久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Jasmine 間諜 callThrough 和 callFake

Jasmine spies callThrough and callFake(Jasmine 間諜 callThrough 和 callFake)
本文介紹了Jasmine 間諜 callThrough 和 callFake的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我有一個場景,我想在調用回調之后在 beforeEach 上調用 done().

I have a scenario whereby I want to call done() on a beforeEach after a callback has been invoked.

我嘗試這樣做:

spyOn(scope, 'onAdmin').and.callThrough().and.callFake(function(){done()})

但我不確定我的行為是否正確.本質上,我想要實現的是能夠在每個回調完成后調用 done() .

But I'm not sure I get the right behaviour. Essentially what I want to achieve is to be able to call done() after each callback is done doing what it does.

更新:解決方法

scope.onAdminBackup = scope.onAdmin;
spyOn(scope, 'onAdmin').and.callFake(function(admin)  {

 scope.onAdminBackup();
 done() ;

})  

推薦答案

我從來沒有將這些類型的函數鏈接在一起,因為在我看來它們似乎做相反的事情.你是說當我調用這個方法 -onAdmin - 在范圍內正常調用它.這就是 jasmine 為我們提供的 callThrough 方法所做的.

I have never chained these kinds of functions together cuz in my mind they seem to do the opposite. You are saying when I call this method -onAdmin - in the scope call it as normal. Which is what the callThrough method jasmine provides for us does.

但是你也鏈接了一個 callFake 方法,所以你說但實際上并沒有調用它,而是調用這個假函數 - 非常矛盾.

But then you are chaining along a callFake method as well so then you say but dont actually call it call this fake function instead - very conflicting.

如果你想在 onAdmin 方法上調用 spy,而不是讓它被解雇,你希望它做其他事情——一些被嘲笑的事情——然后使用 .and.callFake(fn).還要考慮到上面提到的@stefan - 不要調用函數 - callFake 只是想要一個函數作為參數,它會自行調用它.

If you want to call spy on the method onAdmin and instead of it being fired you want it to do something else - something mocked - then use the .and.callFake(fn). Also take into account like @stefan above said - dont invoke the function - callFake is simply wanting a function as a parameter it will take care of calling it itself.

如果沒有向我們展示更多代碼,這可能更符合您的要求.

This might be more along the lines of what you are looking for, if not show us some more code.

spyOn(scope, 'onAdmin')and.callFake(done)

這篇關于Jasmine 間諜 callThrough 和 callFake的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I get my jasmine tests fixtures to load before the javascript considers the document to be quot;readyquot;?(在 javascript 認為文檔“準備好之前,如何讓我的 jasmine 測試裝置加載?) - IT屋-程序員軟件開發技術
What do jasmine runs and waitsFor actually do?(jasmine 運行和等待實際上是做什么的?)
How to provide mock files to change event of lt;input type=#39;file#39;gt; for unit testing(如何提供模擬文件來更改 lt;input type=filegt; 的事件用于單元測試)
How to unit test a chained method using Jasmine(如何使用 Jasmine 對鏈式方法進行單元測試)
How do I inject $rootScope into an AngularJS unit test?(如何將 $rootScope 注入 AngularJS 單元測試?)
Jasmine - How to spy on a function call within a function?(Jasmine - 如何監視函數中的函數調用?)
主站蜘蛛池模板: 美女国产 | 亚洲一区视频在线 | 每日更新av | 精品欧美一区二区三区久久久小说 | av永久| 黄页网址在线观看 | 日韩视频区 | 日本理论片好看理论片 | 成人网视频 | 久久精品一区 | 中文字幕高清一区 | 久久精品欧美视频 | 亚洲一区二区三区桃乃木香奈 | 欧美精品一区二区三区在线播放 | 请别相信他免费喜剧电影在线观看 | 97伦理影院 | 欧美日韩综合 | 日韩视频二区 | 人人干在线 | 国产午夜精品一区二区三区嫩草 | 亚洲精品自拍视频 | 69热视频在线观看 | 东方伊人免费在线观看 | 欧美freesex黑人又粗又大 | 91在线观看免费 | 日韩精品一区二区三区在线播放 | 日韩欧美在线观看视频网站 | 欧美成人h版在线观看 | 毛片免费看 | 亚洲啊v在线 | av网站在线免费观看 | 久久99精品久久久97夜夜嗨 | 欧美精品一区三区 | 91久久久久久久久久久久久 | 亚洲精品久久久久中文字幕欢迎你 | 成人欧美日韩一区二区三区 | 中国一级特黄毛片大片 | 精品国产一区二区国模嫣然 | 第一福利社区1024 | 免费高潮视频95在线观看网站 | 国产综合久久 |