1. 依赖安装
yarn init
yarn add lab code
2. 基本模式
const Lab = require('lab');
const Code = require('code');
const lab = exports.lab = Lab.script();
const expect = Code.expect;
const describe = lab.describe;
const it = lab.test;
const before = lab.before;
const after = lab.after;
describe("app plus test suite",function(){
it('returns true when 1 + 1 equals 2', () => {
expect(1 + 1).to.equal(2);
});
it('returns true when 2 + 1 equals 2', () => {
expect(1 + 2).to.equal(4);
});
})
3. 总结
总的来说使用还是比较简单的,同时类似jasmin测试框架(web),testem 同时facebook的jest 测试框架也是一个不错的选择,后面应该会有jest的相关介绍
testem
4. 参考资料
https://www.npmjs.com/package/lab