Javascript 为什么我的期望没有被回避(开玩笑)?
我正在测试一个基于WebSocket的API,消息处理程序在调用“expect”时暂停(它不进行检查)。甚至对done的调用也没有进行评估Javascript 为什么我的期望没有被回避(开玩笑)?,javascript,jestjs,Javascript,Jestjs,我正在测试一个基于WebSocket的API,消息处理程序在调用“expect”时暂停(它不进行检查)。甚至对done的调用也没有进行评估 describe('When a speed test is triggered', () => { test('Then AWS should send the result to the client', done => { ws.on('open', open = () => { ws.
describe('When a speed test is triggered', () => {
test('Then AWS should send the result to the client', done => {
ws.on('open', open = () => {
ws.send(JSON.stringify({
message: 'start-speed-test-rbsid',
data: RBSID,
platform: "android"
}));
ws.on('message', incoming = data => {
data = JSON.parse(data)
// this gets never evaluated
expect(data.data.status).toBe('IN_PROGRESS')
// execution never gets here
done()
});
})
})
我希望对“expect”的调用进行评估,但根本没有对其进行评估。测试暂停。您是否故意使用全局变量
open
、传入的
和数据
。在严格模式下,它甚至可能失败。很高兴知道,谢谢。有没有关于为什么不叫“完成”的想法?