The impact is that it's not possible to write tests for websocket.onerror.
Prerequisites
Environment check
Node.js version
v22
Reproduction repository
https://github.com/joshua-tj/msw-ws-onerror-test/
test("Connection should error", () =>
new Promise((done, fail) => {
const api = ws.link("wss://example.com/path");
const server = setupServer(
api.addEventListener("connection", () => {
console.log("connecting");
throw new Error("Connection error");
})
);
server.listen();
const connection = new WebSocket("wss://example.com/path");
connection.onerror = (e) => {
console.log("onerror", e);
done();
};
connection.onclose = (e) => {
console.log("onclose", e);
};
connection.onopen = () => {
console.log("onopen");
fail("Connection should not be opened");
};
}));
Reproduction steps
yarn
yarn test
Current behavior
Errors and fails tests as onerror handler is not called
Expected behavior
Should not fail since we handle errors and call done() in test
The impact is that it's not possible to write tests for
websocket.onerror.Prerequisites
Environment check
mswversionNode.js version
v22
Reproduction repository
https://github.com/joshua-tj/msw-ws-onerror-test/
Reproduction steps
yarnyarn testCurrent behavior
Errors and fails tests as
onerrorhandler is not calledExpected behavior
Should not fail since we handle errors and call
done()in test