vitest.config.ts 681 B

123456789101112131415161718192021222324252627282930
  1. import { resolve } from 'path'
  2. import { defineConfig } from 'vitest/config'
  3. import { compilerOptions } from './tsconfig.json'
  4. const resolvePaths = () => {
  5. return Object.fromEntries(
  6. Object.entries(compilerOptions.paths || {}).map(([key, value]) => [
  7. key.replace('/*', ''),
  8. resolve(__dirname, value[0].replace('/*', '')),
  9. ])
  10. )
  11. }
  12. export default defineConfig({
  13. test: {
  14. setupFiles: ['./vitest.setup.ts'],
  15. environment: 'jsdom',
  16. globals: true,
  17. include: ['**/*.spec.{ts,tsx,js,jsx}'],
  18. coverage: {
  19. include: ['src/**/*.ts'],
  20. },
  21. alias: resolvePaths(),
  22. },
  23. resolve: {
  24. extensions: ['.ts', '.tsx', '.js', '.json'],
  25. },
  26. })