cd /news/developer-tools/configuracion-de-vitest-react-testin… · home topics developer-tools article
[ARTICLE · art-12524] src=gist.github.com ↗ pub= topic=developer-tools verified=true sentiment=· neutral

Configuración de Vitest + React Testing Library

The article provides a step-by-step guide for setting up Vitest with React Testing Library in a Vite project. It instructs users to install necessary dependencies (vitest, jsdom, and testing library packages), add specific test scripts to the package.json file, and configure the vite.config.ts file with jsdom as the test environment and globals enabled.

read1 min views25 publishedJun 17, 2025
  1. Vitest
npm install --save-dev vitest jsdom
  1. React Testing Library
npm install --save-dev @testing-library/react @testing-library/dom
  • Todo en un sólo comando
npm install --save-dev @testing-library/react @testing-library/dom vitest jsdom
  1. Crear estos scripts en el package.json
"scripts": {
  "test": "vitest",
  "test:ui": "vitest --ui",
  "coverage": "vitest run --coverage"
}
  1. Configurar vite.config.ts
import { defineConfig } from 'vitest/config';
import react from '@vitejs/plugin-react-swc';

// https://vite.dev/config/
export default defineConfig({
  plugins: [react()],
  test: {
    environment: 'jsdom',
    globals: true,
  },
});
── more in #developer-tools 4 stories · sorted by recency
── more on @vitest 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/configuracion-de-vit…] indexed:0 read:1min 2025-06-17 ·