Skip to content

Commit bc43a97

Browse files
Copilotmiccy
andcommitted
Add WebSocket polyfill for Node.js tests
Co-authored-by: miccy <9729864+miccy@users.noreply.github.com>
1 parent f24ca1d commit bc43a97

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

packages/nodejs/test/setup.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Polyfill WebSocket for Node.js tests
2+
// The @evolu/common package accesses globalThis.WebSocket at import time
3+
import { WebSocket } from "ws";
4+
5+
if (!globalThis.WebSocket) {
6+
// @ts-expect-error - ws WebSocket is compatible enough for our needs
7+
globalThis.WebSocket = WebSocket;
8+
}

packages/nodejs/vitest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { defineConfig } from "vitest/config";
22

33
export default defineConfig({
44
test: {
5+
setupFiles: ["./test/setup.ts"],
56
exclude: ["**/node_modules/**", "**/dist/**"],
67
include: ["test/**/*.test.ts"],
78
coverage: {

0 commit comments

Comments
 (0)