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

期望不要拋出帶參數的函數 - Jasmine

Expect not toThrow function with arguments - Jasmine(期望不要拋出帶參數的函數 - Jasmine)
本文介紹了期望不要拋出帶參數的函數 - Jasmine的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我有獲得 3 個參數的函數.我想檢查這個函數沒有拋出錯誤.我做了這樣的事情:

I have function that gets 3 arguments. I want to check that this function not throwing an error. I did something like this:

expect(myFunc).not.toThrow();

問題是 myFunc 需要獲取參數.如何發(fā)送參數?

The problem is myFunc need to get arguments. How can I send the arguments?

P.S 我試圖傳遞它的參數,但我得到錯誤 myFunc(arg1, arg2, arg3) 不是一個函數.

P.S I tried to pass it argument but I got error that myFunc(arg1, arg2, arg3) is not a function.

推薦答案

toThrow 匹配器需要將函數作為參數傳遞給 expect,這樣你就可以簡單地包裝你的函數調用在匿名函數中:

toThrow matcher requires function to be passed as argument to expect so you can simply wrap your function call in anonymous function:

expect(function() {
    myFunc(arg1, arg2, arg3);
}).not.toThrow();

您也可以使用 綁定創(chuàng)建函數的新版本",在調用時將傳遞提供的參數:

You can also use bind to create new 'version' of your function that when called will be passed provided arguments:

expect(myFunc.bind(null, arg1, arg2, arg3)).not.toThrow();

這篇關于期望不要拋出帶參數的函數 - 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屋-程序員軟件開發(fā)技術
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 - 如何監(jiān)視函數中的函數調用?)
主站蜘蛛池模板: 日韩成人中文字幕 | 中文成人在线 | 激情五月婷婷综合 | 人人干97 | 精品无码三级在线观看视频 | 美女视频黄的 | 日本在线观看视频 | 精品在线一区 | 日韩精品一区二区不卡 | 久久久国产精品入口麻豆 | 精品日韩一区二区 | 欧美激情一区二区三级高清视频 | a在线视频观看 | 免费在线一区二区 | 老司机精品福利视频 | 日韩视频 中文字幕 | h视频在线观看免费 | 欧洲毛片 | 日韩久久久久久 | 久久国产精品一区二区 | 草久在线| 亚洲天堂中文字幕 | 久久尤物免费一区二区三区 | 成人久久18免费网站麻豆 | 青青久草| 国产伦精品一区二区三区高清 | 亚洲精品日韩一区二区电影 | 羞羞的视频免费看 | 三级特黄特色视频 | 久草热视频| 成人免费精品视频 | 免费观看黄色一级片 | 中文字幕免费观看 | 色综合久久久 | 天天躁日日躁狠狠躁2018小说 | 欧美日韩中文字幕 | 久久久久久中文字幕 | 久久精品亚洲欧美日韩久久 | 亚洲精品一二三区 | jdav视频在线观看免费 | 成人午夜在线视频 |