【发布时间】:2017-03-27 08:15:33
【问题描述】:
我正在尝试为我的应用程序在单元测试中启动存根。
我的文件中有这样的内容。
var sinon = require('sinon'),
should = require('should');
require('sinon-stub-promise');
describe('test unit Tests', function(){
describe('My first test', function(){
it('should test a promise', function(){
sinon.stub().resolves('foo')().then(function (value) {
console.log('test');
assert.equal(value, 'not foooo')
})
})
});
我的问题是我似乎无法触发assert.equal error。运行测试时,我可以在输出中看到“test”。但是,测试应该失败,因为值应该是foo 而不是'not foooo'。由于某种原因,它通过了。我不确定原因。有人可以帮我吗?非常感谢!
【问题讨论】:
标签: node.js unit-testing sinon