fix(test): add WebSocket polyfill for Node.js test environment

nostr-tools relay code requires WebSocket which isn't available in
Node.js by default. Adding the ws package polyfill prevents
"ReferenceError: WebSocket is not defined" errors in tests.
This commit is contained in:
Claude
2026-01-07 10:06:25 +00:00
parent bc613dfa8e
commit 04136f79fc

View File

@@ -1,7 +1,13 @@
/**
* Vitest setup file
*
* Polyfills IndexedDB for Node.js test environment.
* This allows Dexie to work in tests without a browser.
* Polyfills browser APIs for Node.js test environment.
*/
// Polyfill IndexedDB - allows Dexie to work in tests
import "fake-indexeddb/auto";
// Polyfill WebSocket - required by nostr-tools relay code
import { WebSocket } from "ws";
// @ts-expect-error - polyfilling global WebSocket for Node.js
globalThis.WebSocket = WebSocket;