mocha
创建add.js
function add(x,y){
return x+y
}
module.exports=add;
----
add.test.js
//断言库
var chai=require('chai');
//断言风格 should assert expect
var expect=chai.expect;
var add=require('../add')
//测试套件
describe('加法函数测试',function(){
// 测试用例
it('1加上1等于2',function(){
expect(add(1,1)).to.be.equal(2)
})
it.skip('2+3!=4',function(){
expect(add(2,3)).to.be.not.equal(4)
})
it('false不为真',function(){
expect(false).to.not.be.ok;
})
before(function(){
console.log('所有测试用例之----')
})
after(function(){
console.log('所有测试用例之----')
})
beforeEach(function(){
console.log('meiyige测试用例之前')
})
afterEach(function(){
console.log('每一个测试用例之。。。。')
})
})
------------------
package.json
{
"name": "mocha-demos",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha --compilers js:babel-core/register "
},
"keywords": [
"testing",
"Mocha"
],
"author": "",
"license": "MIT",
"devDependencies": {
"babel-core": "~6.2.1",
"babel-preset-es2015": "~6.1.18",
"chai": "~3.4.1",
"mocha": "~2.3.4",
"mochawesome": "~1.2.1"
},
"dependencies": {
"node-fetch": "~1.3.3",
"superagent": "~1.4.0"
}
}
生成html文件?????

浙公网安备 33010602011771号