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

有沒有辦法用 Jasmine 驗證間諜執行的順序?

Is there a way to verify the order of spy executions with Jasmine?(有沒有辦法用 Jasmine 驗證間諜執行的順序?)
本文介紹了有沒有辦法用 Jasmine 驗證間諜執行的順序?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我有兩個對象被 Jasmine 設置為間諜:

I've got two objects that have been set up as spies with Jasmine:

spyOn(obj, 'spy1');
spyOn(obj, 'spy2');

我需要驗證對 spy1 的調用是否在對 spy2 的調用之前.我可以檢查它們是否都被調用:

I need to verify that calls to spy1 come before calls to spy2. I can check if both of them are called:

expect(obj.spy1).toHaveBeenCalled();
expect(obj.spy2).toHaveBeenCalled();

但即使首先調用 obj.spy2() 也會通過.有沒有一種簡單的方法可以驗證一個在另一個之前被調用?

but this will pass even if obj.spy2() was called first. Is there an easy way of verifying that one was called before the other?

推薦答案

貌似 Jasmine 的人看到這個帖子或者其他人喜歡,因為 這個功能存在.我不確定它已經存在了多久——他們所有回到 2.6 的 API 文檔都提到了它,盡管他們存檔的舊式文檔都沒有提到它.

Looks like the Jasmine folks saw this post or others like it, because this functionality exists. I'm not sure how long it's been around -- all of their API docs back to 2.6 mention it, though none of their archived older style docs mention it.

toHaveBeenCalledBefore(預期)
expect 實際值(a Spy) 在另一個 間諜.

toHaveBeenCalledBefore(expected)
expect the actual value (a Spy) to have been called before another Spy.

參數:

Name        Type    Description
expected    Spy     Spy that should have been called after the actual Spy.

您的示例失敗看起來像 Expected spy spy1 to have been called before spy spy2.

A failure for your example looks like Expected spy spy1 to have been called before spy spy2.

這篇關于有沒有辦法用 Jasmine 驗證間諜執行的順序?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 - 如何監視函數中的函數調用?)
主站蜘蛛池模板: 久在线视频播放免费视频 | 国产精品99久久久久久宅男 | 羞羞视频网站免费观看 | 视频一区二区在线观看 | 91嫩草精品 | 99久久婷婷国产综合精品电影 | 国产男女猛烈无遮掩视频免费网站 | 欧美黄a | 精品国产91乱码一区二区三区 | 中国美女av | 九九九久久国产免费 | 欧美精品video | 99久久免费精品国产男女高不卡 | 国产丝袜一区二区三区免费视频 | 我想看国产一级毛片 | 黄色国产视频 | 欧美一区中文字幕 | 欧美亚洲国产一区二区三区 | 日韩午夜 | 波多野结衣一区二区三区在线观看 | 激情国产在线 | 日本aⅴ中文字幕 | 欧美一区二区成人 | 日韩波多野结衣 | 在线色网| 一区二区精品在线 | 欧美一二三 | 欧美日韩不卡在线 | 特级黄一级播放 | 99这里只有精品视频 | 九九色综合 | 精品欧美一区二区三区久久久 | 成人国产网站 | av永久 | 久久久久久久久蜜桃 | 欧美成人精品二区三区99精品 | 人人干人人干人人干 | 国产精品欧美一区二区三区不卡 | 精品美女久久久 | 亚洲 欧美 另类 综合 偷拍 | 伊色综合久久之综合久久 |