Files
flyer-crawler.projectium.com/vite.config.ts
Torben Sorensen cea3586984
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 4m24s
more db unit tests - best o luck !
2025-12-06 22:58:37 -08:00

77 lines
3.1 KiB
TypeScript

// vite.config.ts
import path from 'path';
import { defineConfig } from 'vitest/config';
import react from '@vitejs/plugin-react';
/**
* This is the main configuration file for Vite and the Vitest 'unit' test project.
* When running `vitest`, it is orchestrated by `vitest.workspace.ts`, which
* separates the unit and integration test environments.
*/
export default defineConfig({
// Vite-specific configuration for the dev server, build, etc.
// This is inherited by all Vitest projects.
plugins: [react()],
server: {
port: 3000,
host: '0.0.0.0',
},
resolve: {
alias: {
// Use __dirname for a more robust path resolution
'@': path.resolve(__dirname, './src'),
// This alias ensures that any import of 'services/logger' is resolved
// to the browser-safe client version during the Vite build process.
// Server-side code should explicitly import 'services/logger.server'.
'services/logger': path.resolve(__dirname, './src/services/logger.client.ts'),
},
},
// Vitest-specific configuration for the 'unit' test project.
test: {
// Name this project 'unit' to distinguish it in the workspace.
name: 'unit',
// By default, Vitest does not suppress console logs.
// The onConsoleLog hook is only needed if you want to conditionally filter specific logs.
// Keeping the default behavior is often safer to avoid missing important warnings.
// Disable file parallelism to run tests sequentially (replaces --no-threads)
fileParallelism: false,
environment: 'jsdom',
globalSetup: './src/tests/setup/global-setup.ts',
setupFiles: ['./src/tests/setup/tests-setup-unit.ts'],
// Explicitly include all test files that are NOT integration tests.
include: ['src/**/*.test.{ts,tsx}'],
// Exclude integration tests and other non-test files from the unit test runner.
exclude: [
'**/node_modules/**',
'**/dist/**',
'src/tests/integration/**', // Exclude the entire integration test directory
'**/*.e2e.test.ts'
],
coverage: {
provider: 'v8',
// We remove 'text' here. The final text report will be generated by `nyc` after merging.
reporter: [
// Add maxCols to suggest a wider output for the text summary.
['text', { maxCols: 200 }],
'html', 'json'],
// hanging-process reporter helps identify tests that do not exit properly - comes at a high cost tho
//reporter: ['verbose', 'html', 'json', 'hanging-process'],
reportsDirectory: './.coverage/unit',
clean: true,
reportOnFailure: true, // This ensures the report generates even if tests fail
include: ['src/**/*.{ts,tsx}'],
// Refine exclusions to be more comprehensive
exclude: [
'src/main.tsx',
'src/types.ts',
'src/tests/**', // Exclude all test setup and helper files
'src/**/*.test.{ts,tsx}', // Exclude test files themselves
'src/**/*.stories.{ts,tsx}', // Exclude Storybook stories
'src/**/*.d.ts', // Exclude type definition files
'src/components/icons/**', // Exclude icon components if they are simple wrappers
],
},
},
});