【发布时间】:2020-12-04 15:35:06
【问题描述】:
大家好,这个测试应该失败,但它通过了,同时也抛出了断言错误。
describe('Testing getAllrecipes',()=>{
it('1. Test get All Recipes',(done)=>{
var uri = "mongodb://localhost:27017";
var dbname = "testRecipes";
var collectionName = "testCollectionClean";
let driver = new MongoDriver(uri,dbname,collectionName);
driver.dropCollection(); //Clean collection for testing... NEVER CALL ON PRODUCTION COLLECTION
driver.addMockData();
driver.getAllRecipe().then((promise)=>{
assert.deepEqual(promise,'fake news')
done();
}).catch((e)=>{
console.log(e);
done();
});
});
})
控制台:
AssertionError: expected [] to deeply equal 'fake news'
{
showDiff: true,
actual: [],
expected: 'fake news'
}
✓ 1. Test get All Recipes
8 passing (60ms)
如何让测试返回失败?
【问题讨论】:
标签: javascript node.js chai