gpt4 book ai didi

javascript - 'pending' 测试在 Mocha 中意味着什么,我怎样才能让它通过/失败?

转载 作者:搜寻专家 更新时间:2023-11-01 05:09:16 26 4
gpt4 key购买 nike

我正在运行我的测试并注意到:

18 passing (150ms)
1 pending

我以前没见过这个。之前的测试要么通过,要么失败。超时导致失败。我可以看到哪个测试失败了,因为它也是蓝色的。但是它有超时时间。这是一个简化版本:

test(`Errors when bad thing happens`), function(){
try {
var actual = doThing(option)
} catch (err) {
assert(err.message.includes('invalid'))
}
throw new Error(`Expected an error and didn't get one!`)
}
  • “待定”是什么意思? 当 Mocha 退出且节点不再运行时,测试如何“挂起”?
  • 为什么这个测试没有超时?
  • 如何使测试通过或失败?

谢谢!

最佳答案

当您无意中提前关闭测试的 it 方法时,Mocha 可能最终将测试显示为“待定”,例如:

// Incorrect -- arguments of the it method are closed early
it('tests some functionality'), () => {
// Test code goes here...
};

it 方法的参数应该包括测试函数定义,例如:

// Correct
it('tests some functionality', () => {
// Test code goes here...
});

关于javascript - 'pending' 测试在 Mocha 中意味着什么,我怎样才能让它通过/失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49050799/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com