From 3e82dd943d444d0f53075ac50d454d6343c8da87 Mon Sep 17 00:00:00 2001 From: Kurdistan Tech Ministry Date: Thu, 11 Dec 2025 01:56:33 +0300 Subject: [PATCH] fix(test): add polyfill shims for vitest environment --- web/src/tests/mocks/buffer-shim.ts | 2 ++ web/src/tests/mocks/global-shim.ts | 1 + web/src/tests/mocks/process-shim.ts | 1 + web/vite.config.ts | 5 +++++ 4 files changed, 9 insertions(+) create mode 100644 web/src/tests/mocks/buffer-shim.ts create mode 100644 web/src/tests/mocks/global-shim.ts create mode 100644 web/src/tests/mocks/process-shim.ts diff --git a/web/src/tests/mocks/buffer-shim.ts b/web/src/tests/mocks/buffer-shim.ts new file mode 100644 index 00000000..076280d7 --- /dev/null +++ b/web/src/tests/mocks/buffer-shim.ts @@ -0,0 +1,2 @@ +import { Buffer } from 'buffer'; +export default Buffer; diff --git a/web/src/tests/mocks/global-shim.ts b/web/src/tests/mocks/global-shim.ts new file mode 100644 index 00000000..a91bc1e3 --- /dev/null +++ b/web/src/tests/mocks/global-shim.ts @@ -0,0 +1 @@ +export default globalThis; diff --git a/web/src/tests/mocks/process-shim.ts b/web/src/tests/mocks/process-shim.ts new file mode 100644 index 00000000..2e404777 --- /dev/null +++ b/web/src/tests/mocks/process-shim.ts @@ -0,0 +1 @@ +export default { env: {} }; diff --git a/web/vite.config.ts b/web/vite.config.ts index 9fc7f2fb..efe8d35e 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -10,6 +10,11 @@ export default defineConfig(() => ({ globals: true, environment: 'jsdom', setupFiles: './src/tests/setup.ts', + alias: { + 'vite-plugin-node-polyfills/shims/buffer': path.resolve(__dirname, './src/tests/mocks/buffer-shim.ts'), + 'vite-plugin-node-polyfills/shims/global': path.resolve(__dirname, './src/tests/mocks/global-shim.ts'), + 'vite-plugin-node-polyfills/shims/process': path.resolve(__dirname, './src/tests/mocks/process-shim.ts'), + }, }, server: { host: "::",