import { defineConfig } from 'vitest/config';
import react from '@vitejs/plugin-react';
import { fileURLToPath } from 'url';

export default defineConfig({
    plugins: [react()],
    test: {
        environment: 'happy-dom',
        environmentOptions: {
            happyDOM: {
                settings: {
                    disableIframePageLoading: true,
                    disableJavaScriptFileLoading: true,
                    disableCSSFileLoading: true,
                }
            }
        },
        globals: true,
        setupFiles: ['./tests/setup.tsx'],
        alias: [
            { find: 'next/server', replacement: 'next/server.js' },
            { find: '@payload-config', replacement: fileURLToPath(new URL('./tests/__mocks__/payload-config.ts', import.meta.url)) },
            { find: '@', replacement: fileURLToPath(new URL('./', import.meta.url)) },
        ],
        exclude: ['**/node_modules/**', '**/.next/**'],
        server: {
            deps: {
                inline: ['next-intl', '@mintel/next-utils'],
            },
        },
    },
});
