得到以下失败的测试用例,我不知道为什么:
foo.js
async function throws() {
throw 'error';
}
async function foo() {
try {
await throws();
} catch(e) {
console.error(e);
throw e;
}
}
测试.js
const foo = require('./foo');
describe('foo', () => {
it('should log and rethrow', async () => {
await expect(foo()).rejects.toThrow();
});
});
我希望 foo 抛出但由于某种原因它只是解决并且测试失败:
FAILED foo › should log and rethrow - Received function did not throw
可能缺少异步等待抛出行为的一些基本细节。
catspeake
尚方宝剑之说
PIPIONE
慕神8447489
随时随地看视频慕课网APP
相关分类