diff --git a/tests/setup.ts b/tests/setup.ts new file mode 100644 index 00000000..abb2ead4 --- /dev/null +++ b/tests/setup.ts @@ -0,0 +1,5 @@ +import { vi } from 'vitest' +import { webcrypto } from 'node:crypto' + +// Mock the global crypto object to use Node.js webcrypto +vi.stubGlobal('crypto', webcrypto) diff --git a/vitest.config.ts b/vitest.config.ts index cb2d2d32..c4ce30d0 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -5,7 +5,8 @@ export default defineConfig({ test: { globals: true, // so can use `describe`/`it` without importing them environment: 'node', - include: ['tests/**/*.test.{js,ts}'], + include: ['tests/**/*.test.{js,ts}'], + setupFiles: ['./tests/setup.ts'], }, define: {