为什么我的期望电话没有被取消(笑话)?

时间:2019-09-02 13:10:39

标签: javascript jestjs

我正在测试基于WebSocket的API,消息处理程序在调用“期望”时停滞了(它不进行检查)。甚至没有致电完成来评估。

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()
            });
        })
    })

我希望对“期望”的调用能够被撤消,但根本不会进行评估。测试停顿了。

0 个答案:

没有答案