我不知道为什么但是这会将成功返回为挂起,但失败成功返回使用mocha
进行测试失败
describe('createToken', function() {
it('should return the token', utils.createToken('somestring', function(err, auth){
expect(typeof auth.token).to.equal('string'); // pending but should be success
expect(err).to.equal(null); // pending
expect(true).to.equal(false); // fail
}));
})
我和这段代码有什么问题?提前谢谢。
答案 0 :(得分:1)
尝试使用done()
进行测试,如下所示
describe('createToken', function() {
it('should return the token', function(done) {
utils.createToken('somestring', function(err, auth){
expect(typeof auth.token).to.equal('string'); // pending but should be success
expect(err).to.equal(null); // pending
expect(true).to.equal(false); // fail
done();
})
});
})