mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
20 lines
657 B
TypeScript
20 lines
657 B
TypeScript
import { test, expect } from "bun:test";
|
|
|
|
test("WebSocket error event snapshot", async () => {
|
|
const ws = new WebSocket("ws://127.0.0.1:8080");
|
|
const { promise, resolve } = Promise.withResolvers();
|
|
ws.onerror = error => {
|
|
resolve(error);
|
|
};
|
|
const error = await promise;
|
|
expect(error).toMatchSnapshot("Snapshot snapshot");
|
|
expect(Bun.inspect(error)).toMatchSnapshot("Inspect snapshot");
|
|
});
|
|
|
|
test("ErrorEvent with no message", async () => {
|
|
const error = new ErrorEvent("error");
|
|
expect(error.message).toBe("");
|
|
expect(Bun.inspect(error)).toMatchSnapshot("Inspect snapshot");
|
|
expect(error).toMatchSnapshot("Snapshot snapshot");
|
|
});
|