是jest
的新功能,我之前使用chai
+ mocha
我喜欢使用柴expect
风格。
所以有没有存在的nodejs模块可以让我像柴风格一样开玩笑?
我想使expect(isOPDSAgent(ua)).toBeTruthy();
变成expect(isOPDSAgent(ua)).to.be.ok;
这将使切换旧单元测试变得容易
我尝试在npm中搜索jest + chai,但找不到它
玩笑支持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