Skip to content

Support async listeners so that a slow/stuck in WebSocket.CONNECTING can be simulated #711

@sfc-gh-jtjhin

Description

@sfc-gh-jtjhin

Use case: we've implemented our own re-try logic that has a timeout if the web socket is stuck in connecting. And I would like to write tests for it

Another use case: short delay in between messages from server to client

Reply from @kettanaito in discussion

Hi. Yeah, we might want to support async listeners, too. That's already a thing for HTTP requests in Interceptors. Shouldn't be a big task to add that support for WebSocket. Mostly comes down to swapping this.emitter.emit with emitAsync(this.emitter, ...). You would then be able to use await delay() from msw in the connection listener to simulate pending connection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions