[英]Module to use jest as chai expect style?
我是jest
新手,我之前使用過chai
+ mocha
。 我喜歡使用chai
的expect
風格。 是否有任何 nodejs 模塊可以讓我像 chai 風格一樣寫jest
?
相反, expect(isOPDSAgent(ua)).toBeTruthy();
我想要expect(isOPDSAgent(ua)).to.be.ok;
這將使切換舊的單元測試變得容易。
我嘗試搜索,但找不到。 任何幫助表示贊賞!
jest 支持setupFiles ,你應該能夠
package.json
{
// ...
"devDependencies": {
"jest": // ...
"chai": // ...
},
"jest": {
"setupFiles": [
"<rootDir>/setupChai.js"
]
}
}
setupChai.js
// this should overwrite the global expect provided by jest
global.expect = require('chai').expect
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.