DEV Community

Discussion on: React Testing Setup: Vitest + TypeScript + React Testing Library

Collapse
 
sahityaaryan profile image
Sahitya Aryan

Here you didn't mentioned about the configurations in the "vitest.config.ts" it's not detecting the "jest-dom" lib from the vite.config.ts.

It needs vitest.config.ts

import { defineConfig } from 'vitest/config';

export default defineConfig({

test: {
globals: true, // this allows me to use describe, it, expect anywhere within the project without importing them
setupFiles: './tests/setup.ts',
environment: 'jsdom',
include: ['*/.{test,spec}.{js,ts,tsx,jsx}'],
},

});

Now everything will work