mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-11 16:07:15 +02:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user