import { defineConfig } from 'vitest/config'; import { resolve } from 'path'; /** * Vitest configuration for eslint-plugin-postgresql-security package * * @description * Configures Vitest for testing PostgreSQL ESLint rules with the following setup: * - Node environment for running ESLint rule tests * - Coverage tracking with v8 provider * - JUnit reporting for CI/CD pipeline integration */ export default defineConfig({ root: __dirname, // ponytail: alias devkit to source so vitest-direct runs don't need a pre-built dist resolve: { alias: { // Every rule test runs on ESLint and on oxlint: vitest.dual-rule-tester.ts. '@typescript-eslint/rule-tester': resolve( __dirname, '../../vitest.dual-rule-tester.ts', ), '@interlace/eslint-devkit': resolve( __dirname, '../eslint-devkit/src/index.ts', ), }, }, test: { /* * Vitest's 5s default is tuned for unit tests on an idle machine. These run * under a turbo fan-out of ~47 concurrent tasks, where an I/O-bound suite is * routinely starved and mis-reports contention as failure. A genuine hang * still fails — at 30s instead of 5s. * * `hookTimeout` does NOT inherit `testTimeout`; it stays at 10s unless set, * which fails as "Hook timed out in 10000ms" rather than as a test failure. */ testTimeout: 30_000, hookTimeout: 30_000, globals: true, environment: 'node', watch: false, include: ['src/**/*.test.ts', 'src/**/*.spec.ts'], // Setting `exclude` replaces vitest's defaults — spread them back in and // add build-artifact dirs so stale outputs can never shadow real tests. exclude: [ // SDK interface-compat suites import third-party SDKs, not our code, and // cost minutes on a cold module cache. They run via // vitest.compat.config.mts / sdk-compatibility.yml — never in the default // run that backs `turbo run test` and the lefthook pre-commit hook. 'src/__compatibility__/**', '**/node_modules/**', '**/dist/**', '**/cypress/**', '**/.{idea,git,cache,output,temp}/**', '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*', '**/.next/**', '**/.turbo/**', '**/storybook-static/**', '**/coverage/**', ], passWithNoTests: false, globalSetup: ['../../vitest.global-setup.ts'], name: { label: 'pg', color: 'cyan' }, // Use vmThreads for better performance pool: 'vmThreads', coverage: { enabled: true, provider: 'v8', // Coverage ratchet — policy target is 100/100/100/100 (docs/QUALITY_STANDARDS.md §2). // Pinned at the 100% policy target — this branch is the integration target for the test wave. thresholds: { lines: 100, statements: 100, functions: 100, branches: 100, }, reportOnFailure: true, reportsDirectory: './coverage', include: ['src/**/*.ts'], exclude: ['node_modules/', 'dist/', '**/*.test.ts', '**/*.spec.ts'], ignoreClassMethods: ['context.report'], clean: true, reporter: ['text', 'text-summary', 'html', 'lcov'], watermarks: { lines: [80, 90], branches: [70, 80], functions: [80, 90], statements: [80, 90], }, }, reporters: ['default', 'junit'], outputFile: { junit: './test-results/junit.xml', }, }, });