【发布时间】:2019-04-29 16:35:00
【问题描述】:
我正在编写验证文本的代码。这就是我测试它的方式。但我不想在单元测试中使用 try--catch 。请给我一个更好的方法。
it('Testing if hook errors on invalid description.', async () => {
try {
workRequest.requestor = 'John';
workRequest.description = 1;
result = await app.service('dummy').create(workRequest);
} catch (error) {
assert.equal(error.errors.description, 'Description is must be a string');
}
});
【问题讨论】:
标签: javascript node.js unit-testing mocha.js