Skip to content

Browser websockets can't be re-used within vitest test file. #2648

@GeorgeLung

Description

@GeorgeLung

Prerequisites

Environment check

  • I'm using the latest msw version
  • I'm using Node.js version 20 or higher

Browsers

Chromium (Chrome, Brave, etc.)

Reproduction repository

https://github.com/GeorgeLung/msw-vitest-ws-example

Reproduction steps

npm test

Current behavior

For each file, of the two tests only the first passes. The second times out. This is because both of the promises (waiting on a websocket connection) don't resolve.

Expected behavior

All 4 tests to pass.

It's likely the pattern I'm attempting is the issue. In which case, I'd be grateful if the docs could be updated to demonstrate the correct pattern.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions