有没有办法在测试通过或失败后编写'if'语句?
var assert = require('chai').assert;
var expect = require('chai').expect;
var first = require('../first');
describe('First', function(){
it('first should return hello world', function(){
assert.equal(first(), 'hello world')
});
});
答案 0 :(得分:0)
查看Mocha - before, after, before each, after each hooks
在您的代码中,它将类似于:
describe('First', function(){
afterEach(function() {
// runs after each test in this block
});
after(function() {
// runs after all tests in this block
});
it('first should return hello world', function(){
assert.equal(first(), 'hello world')
// if you want another assertion you can add one here. for example:
assert.notEqual(first(), 'bye world')
});
});