首页 > 其他 > 详细

单元测试UI

时间:2019-03-21 17:38:14      阅读:150      评论:0      收藏:0      [点我收藏+]

cnpm install -g --save mocha   

cnpm install  -g --save chai  

cnpm install -g --save istanbul

const {should,expect,assert} = require(‘chai‘);
const {add,mul} = require(‘./math‘)
describe("#math",()=>{
describe(‘add‘,()=>{
it(‘shoule return 5 when 2+3‘,()=>{
expect(add(2,3),5);
});
it(‘shoule return 5 when 2+3‘,()=>{
expect(add(2,-3),-1);
})
})
describe(‘mul‘,()=>{
it(‘shoule return 5 when 2*3‘,()=>{
expect(add(2,3),6);
});
it(‘shoule return 5 when 2*3‘,()=>{
expect(add(2,-3),-6);
})
})
})

技术分享图片

 

 

这里很重要
"scripts": {

"test": "mocha test/mocha.js",
"cover": "istanbul cover ./node_modules/mocha/bin/_mocha test/mocha.js"
},

 

单元测试UI

原文:https://www.cnblogs.com/joer717/p/10573139.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!