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