Files
metabuilder/frontends/nextjs/vitest.config.ts
johndoe6345789 882c637a06 fix(tests): resolve 4 vitest failure categories in nextjs frontend
- Fix vitest.config.ts fakemui alias path: ../../fakemui → ../../components/fakemui
  (matches tsconfig.json paths; fixes pagination + get-component-icon tests)
- Add vi.mock('server-only') to route.test.ts to prevent server-only guard
  throwing in jsdom environment
- Replace @jest/globals with vitest in workflow-error-handler and
  multi-tenant-context test files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-10 20:54:02 +00:00

38 lines
1.2 KiB
TypeScript

import react from '@vitejs/plugin-react-swc'
import { resolve } from 'path'
import { defineConfig } from 'vitest/config'
export default defineConfig({
plugins: [react()],
test: {
environment: 'jsdom',
globals: true,
include: ['src/**/*.test.{ts,tsx}'],
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
},
deps: {
// Use inline to avoid duplicate React instances in tests
optimizer: {
web: {
include: ['react', 'react-dom']
}
}
}
},
resolve: {
dedupe: ['react', 'react-dom'],
alias: [
// fakemui aliases must be first (more specific matches first)
{ find: /^@\/fakemui\/(.+)$/, replacement: resolve(__dirname, '../../components/fakemui/$1') },
{ find: /^@\/fakemui$/, replacement: resolve(__dirname, '../../components/fakemui/index.ts') },
// dbal-ui alias for shared UI components
{ find: /^@dbal-ui\/(.+)$/, replacement: resolve(__dirname, '../../dbal/shared/ui/$1') },
{ find: /^@dbal-ui$/, replacement: resolve(__dirname, '../../dbal/shared/ui') },
// General @ alias last (least specific)
{ find: /^@\/(.+)$/, replacement: resolve(__dirname, './src/$1') },
],
},
})