Tooling@accelint/vitest-config
@accelint/vitest-config
Shared Vitest configuration presets with coverage, TypeScript paths, and React support for browser and Node.js testing
Shared Vitest configuration used across Accelint projects. Provides standardized testing setup with coverage, TypeScript path support, and React integration.
Installation
pnpm add -D @accelint/vitest-configAvailable Configurations
| Export | Description |
|---|---|
| dom | React/browser testing with React plugin enabled |
| no-dom | Node.js testing without React dependencies |
| mocks/broadcast-channel | Mock implementation of BroadcastChannel API |
Features
- Pre-configured Coverage: Istanbul provider with JSON, LCOV, and text reporters
- TypeScript Path Resolution: Automatic tsconfig path alias support via vite-tsconfig-paths
- React Integration: DOM preset includes @vitejs/plugin-react
- Mock Auto-reset: Automatic mock clearing and restoration between tests
- Zero Watch Mode: Tests run once by default (override with
--watch)
Quick Start
React Component Testing
import { defineConfig, mergeConfig } from 'vitest/config';
import baseConfig from '@accelint/vitest-config/dom';
export default mergeConfig(
baseConfig,
defineConfig({
test: {
globals: true,
environment: 'jsdom',
},
}),
);Node.js Library Testing
import { defineConfig, mergeConfig } from 'vitest/config';
import baseConfig from '@accelint/vitest-config/no-dom';
export default mergeConfig(
baseConfig,
defineConfig({
test: {
// Your custom test config
},
}),
);Simple Re-export
If you don't need custom configuration:
export { default } from '@accelint/vitest-config/dom';Package Scripts
Add these scripts to your package.json:
{
"scripts": {
"test": "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage"
}
}