vitest.config.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { resolve } from 'node:path'
  2. import { fileURLToPath } from 'node:url'
  3. import react from '@vitejs/plugin-react'
  4. import tsconfigPaths from 'vite-tsconfig-paths'
  5. import { configDefaults, defineConfig } from 'vitest/config'
  6. // Some tools like Vitest VSCode extensions, have trouble with resolving relative paths,
  7. // as they use the directory of the test file as `cwd`, which makes them believe that
  8. // `setupFiles` live next to the test file itself. This forces them to always resolve correctly.
  9. const dirname = fileURLToPath(new URL('.', import.meta.url))
  10. export default defineConfig({
  11. plugins: [
  12. react(),
  13. tsconfigPaths({
  14. projects: ['.'],
  15. }),
  16. ],
  17. resolve: {
  18. alias: {
  19. '@ui': resolve(__dirname, './../../packages/ui/src'),
  20. },
  21. },
  22. test: {
  23. globals: true,
  24. environment: 'jsdom', // TODO(kamil): This should be set per test via header in .tsx files only
  25. setupFiles: [
  26. resolve(dirname, './tests/setup/polyfills.ts'),
  27. resolve(dirname, './tests/vitestSetup.ts'),
  28. resolve(dirname, './tests/setup/radix.js'),
  29. ],
  30. // Don't look for tests in the nextjs output directory
  31. exclude: [
  32. ...configDefaults.exclude,
  33. `.next/*`,
  34. 'tests/features/logs/logs-query.test.tsx',
  35. 'tests/features/reports/storage-report.test.tsx',
  36. ],
  37. reporters: [['default']],
  38. coverage: {
  39. reporter: ['text', 'text-summary', 'lcov'],
  40. exclude: [
  41. '**/*.test.ts',
  42. '**/*.test.tsx',
  43. '**/base64url.ts', // [Jordi] Tests for this file exist in https://github.com/briven-community/base64url-js/blob/main/src/base64url.test.ts so we can ignore.
  44. ],
  45. include: ['lib/**/*.ts'],
  46. },
  47. },
  48. })