44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
/**
|
|
* Vitest Browser Mode Configuration for Component Tests
|
|
*
|
|
* Uses Playwright to run component tests in a real browser instead of jsdom.
|
|
* This solves styled-components + React 19 compatibility issues.
|
|
*
|
|
* Run with: pnpm test:components
|
|
*
|
|
* @see https://vitest.dev/guide/browser/
|
|
* @see https://vitest.dev/guide/browser/component-testing
|
|
*/
|
|
|
|
import { defineConfig } from 'vitest/config';
|
|
import react from '@vitejs/plugin-react';
|
|
import { playwright } from '@vitest/browser-playwright';
|
|
import path from 'path';
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
test: {
|
|
name: 'browser',
|
|
// Component and hook tests only
|
|
include: ['src/**/*.spec.tsx', 'src/**/hooks/*.test.tsx', 'src/**/components/*.test.tsx'],
|
|
exclude: [
|
|
'node_modules/**',
|
|
'dist/**',
|
|
'e2e/**',
|
|
'**/*.d.ts',
|
|
],
|
|
browser: {
|
|
enabled: true,
|
|
provider: playwright(),
|
|
instances: [{ browser: 'chromium' }],
|
|
headless: true,
|
|
},
|
|
// Use vitest-browser-react for rendering
|
|
setupFiles: ['./vitest.browser.setup.ts'],
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
},
|
|
},
|
|
});
|