我是Jest单元测试的新手,我一直在使用Mocha ...
我的问题与下面的基本代码和单元测试有关,我有一个uncovered line
,看不到为什么?
任何帮助/指导都将不胜感激,我确信我缺少一些愚蠢的东西。
index.js(如下)
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
module.exports = {
async testfunction() {
await sleep(500);
return 'Hello World !'
}
}
index.test.js(如下)
const myfunctions = require('.');
test('testing testfunction from myfunctions', async () => {
expect(await myfunctions.testfunction()).toBe('Hello World !')
});
使用cli命令jest --coverage