我当前正在使用摩卡咖啡和断言库。
我试图在我的单位测试中遇到一个例外的情况 - 但是从文档看我的运气并没有太多运气。
当前正在使用的代码以下块:
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_modulesshouldcjsshould.js:275:17)
at Assertion.value (node_modulesshouldcjsshould.js:356:19)
at Context.<anonymous> (commonspecknexDBServiceSpec.js:213:25)
是否有人遇到了这个问题,或者可以给我一些有关出错的指导?
它的工作正好是您设置的操作。
您告诉您应该,您的功能应该引发一个例外" U WOT M8"。但是它没有,因此应该失败。
期望(应该(应该投掷。