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

用于 Rails 3.1+ 的 Jasmine 與 Mocha JavaScript 測試

Jasmine vs. Mocha JavaScript testing for Rails 3.1+(用于 Rails 3.1+ 的 Jasmine 與 Mocha JavaScript 測試)
本文介紹了用于 Rails 3.1+ 的 Jasmine 與 Mocha JavaScript 測試的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我有 Jasmine 的經驗,并且非常喜歡它.有沒有人有 Jasmine 和 Mocha 的經驗,特別是 Rails?我想知道是否值得切換.

I have experience with Jasmine and do like it quite a bit. Does anyone have experience with both Jasmine and Mocha, specifically for Rails? I am wondering if it's worth switching to.

推薦答案

我在 Jasmine 和 Mocha 都做過測試.首先,切換相對容易.基本的 describeit BDD 模式是相同的.您將需要更改執行斷言的方式并切換到異步測??試的不同接口.總體而言,它們具有可比性.

I have done testing in both Jasmine and Mocha. First, switching is relatively easy. The basic describe and it BDD pattern is identical. You will need to change how you do your assertions and switch to a different interface for asynchronous tests. Overall they are comparable.

Mocha 的異步接口更簡單、更一致.測試和設置可以是同步的也可以是異步的,這很棒.這一點,再加上 TJ Holowaychuck 是一位史詩般的密碼詩人,這些都是嘗試 Mocha 的好理由.

Mocha's asynchronous interface is much simpler and more consistent. Tests and setup can be either synchronous or asynchronous, which is great. This, plus the fact that TJ Holowaychuck is an epic code poet are good reasons to try Mocha.

我確實認為 Jasmine 匹配器更易于閱讀且更優雅,尤其是與 jasmine-jquery 插件配對時.Mocha 通常與單獨的斷言庫配對,如果您正在進行瀏覽器內測試,通常是 chai.js 或 should.js 用于僅節點測試.我對 chai 的 assert.equal() 界面很滿意,但 Jasmine 風格的 expect($("#central_errors").html()).toContain("must provide a name"); 對我來說似乎更優雅.我不喜歡帶有點分隔句子的 chai.js expect(42).to.be.above(41) 樣式界面,因為它在聽覺上效果不佳.

I do think the Jasmine matchers are easier to read and more elegant, especially when paired with the jasmine-jquery plugin. Mocha is usually paired with a separate library for assertions, often chai.js if you are doing in-browser testing or should.js for node-only testing. I am happy with chai's assert.equal() interface, but the Jasmine style expect($("#central_errors").html()).toContain("must provide a name"); seems more elegant to me. I am not a fan of the chai.js expect(42).to.be.above(41) style interface with dot-delimited sentences because it doesn't work well aurally.

歸根結底,這是一個個人偏好問題,我強烈建議您花一天左右的時間編寫 Mocha 測試而不是 Jasmine,看看感覺如何.完全值得投資,即使您決定堅持使用 Jasmine,您也將從第一手知識的地方這樣做,并了解解決 Jasmine 解決的一些問題的其他方法.我試過了,我堅持使用 Mocha,部分原因是押注 TJ 是一個不錯的選擇,但 Jasmine 也是一個成熟、可靠且被廣泛采用的庫.

Ultimately, this is a personal preference question and I highly encourage you to just spend a day or so writing Mocha tests instead of Jasmine and see how it feels. Totally a worthwhile investment, even if you decide to stick with Jasmine you will be doing so from a place of first-hand knowledge and have an awareness of other ways to solve some of the problems Jasmine solves. I tried it and I'm sticking with Mocha partly because betting on TJ is a good bet, but Jasmine is also a mature, solid, and widely adopted library.

這篇關于用于 Rails 3.1+ 的 Jasmine 與 Mocha JavaScript 測試的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 - 如何監視函數中的函數調用?)
主站蜘蛛池模板: 久久在线 | 国产精品一区二区久久 | 激情欧美日韩一区二区 | 婷婷国产一区 | 久草视频网站 | 日日噜噜噜夜夜爽爽狠狠视频97 | 日韩在线观看网站 | 欧美日韩在线高清 | 国产一区二区三区精品久久久 | 国产成人精品在线播放 | 国产三区在线观看视频 | 91偷拍精品一区二区三区 | 欧美日韩成人在线 | 亚洲精品乱码久久久久久9色 | 国产男女猛烈无遮掩视频免费网站 | 亚洲h在线观看 | 精品一区二区在线观看 | av一级久久 | 欧美在线一区二区三区四区 | 1区2区3区视频 | 欧美精品一区二区在线观看 | 亚洲首页| 高清av电影| 日韩在线免费视频 | 日韩精品久久一区二区三区 | 精品国产一级片 | 在线观看www | 超碰天天 | 91在线精品一区二区 | 91中文| 91精品久久久久久久久久小网站 | 欧美日韩一区二区在线观看 | 亚洲狠狠爱 | 在线视频国产一区 | 国产精品久久久久久久免费大片 | 天天插天天搞 | 亚洲综合婷婷 | 99久久国产免费 | 91视频麻豆| 久久99精品久久久久久 | 91看片官网 |