【发布时间】:2019-07-03 20:41:32
【问题描述】:
我目前正在使用 Mocha 和断言库 should.js
我正在尝试在我的单元测试中运行一个会引发异常的情况 - 但从查看文档来看,到目前为止我还没有太多运气让它工作。
目前正在使用以下代码块:
it('Adds a new employee to the db - FAILS', funct
let employeeObj = {
"Title": "Mr",
"FirstName": "Keanu ",
"LastName": "Reeves",
"Username": "KeanuReeves2",
"Password": "Password",
"Email": "keanu@reeves.com",
"IsActive": true
};
should(function () {
db.AddNewEmployee(employeeObj);
}).throw("U wot m8");
done();
});
我不断收到错误:
AssertionError: expected Function { name: '' } to throw exception
at Assertion.fail (node_modules\should\cjs\should.js:275:17)
at Assertion.value (node_modules\should\cjs\should.js:356:19)
at Context.<anonymous> (common\spec\knexDBServiceSpec.js:213:25)
有没有人遇到过这个问题或者能给我一些关于哪里出错的指导?
【问题讨论】:
标签: node.js mocha.js should.js