Testing a React Application with Vitest and React Testing Library

This page summarizes the projects mentioned and recommended in the original post on dev.to

SurveyJS - JavaScript Form Builder with No-Code UI & Built-In JSON Schema Editor
Add the SurveyJS white-label form builder to your JavaScript app (React/Angular/Vue3). Build complex JSON forms without coding. Fully customizable, works with any backend, perfect for data-heavy apps. Learn more.
surveyjs.io
featured
InfluxDB – Built for High-Performance Time Series Workloads
InfluxDB 3 OSS is now GA. Transform, enrich, and act on time series data directly in the database. Automate critical tasks and eliminate the need to move data externally. Download now.
www.influxdata.com
featured
  1. vite-react-ts-vitest-template

    Template for Vite+React+Vitest+pnpm

    You can access full project here:

  2. SurveyJS

    JavaScript Form Builder with No-Code UI & Built-In JSON Schema Editor. Add the SurveyJS white-label form builder to your JavaScript app (React/Angular/Vue3). Build complex JSON forms without coding. Fully customizable, works with any backend, perfect for data-heavy apps. Learn more.

    SurveyJS logo
  3. vite

    Next generation frontend tooling. It's fast!

    import { describe, it, expect } from 'vitest' import { render, screen, fireEvent } from '@testing-library/react' import App from '../App' describe('App component', () => { it('renders Vite and React logos with correct links', () => { render() const viteLogo = screen.getByRole('img', { name: /Vite logo/i }); const reactLogo = screen.getByAltText('React logo') expect(viteLogo).toBeInTheDocument() expect(reactLogo).toBeInTheDocument() expect(viteLogo.closest('a')).toHaveAttribute('href', 'https://vitejs.dev') expect(reactLogo.closest('a')).toHaveAttribute('href', 'https://react.dev') }) it('renders the initial count correctly', () => { render() const button = screen.getByRole('button', { name: /count is 0/i }) expect(button).toBeInTheDocument() }) it('increments count when button is clicked', () => { render() const button = screen.getByRole('button', { name: /count is 0/i }) fireEvent.click(button) expect(button).toHaveTextContent('count is 1') }) it('renders text content correctly', () => { render() const title = screen.getByText('Vite \+ React') const editText = screen.getByText((content, _) => content.includes('Edit') && content.includes('save to test HMR')) const docsText = screen.getByText('Click on the Vite and React logos to learn more') expect(title).toBeInTheDocument() expect(editText).toBeInTheDocument() expect(docsText).toBeInTheDocument() }) })

  4. React

    The library for web and native user interfaces.

    import { describe, it, expect } from 'vitest' import { render, screen, fireEvent } from '@testing-library/react' import App from '../App' describe('App component', () => { it('renders Vite and React logos with correct links', () => { render() const viteLogo = screen.getByRole('img', { name: /Vite logo/i }); const reactLogo = screen.getByAltText('React logo') expect(viteLogo).toBeInTheDocument() expect(reactLogo).toBeInTheDocument() expect(viteLogo.closest('a')).toHaveAttribute('href', 'https://vitejs.dev') expect(reactLogo.closest('a')).toHaveAttribute('href', 'https://react.dev') }) it('renders the initial count correctly', () => { render() const button = screen.getByRole('button', { name: /count is 0/i }) expect(button).toBeInTheDocument() }) it('increments count when button is clicked', () => { render() const button = screen.getByRole('button', { name: /count is 0/i }) fireEvent.click(button) expect(button).toHaveTextContent('count is 1') }) it('renders text content correctly', () => { render() const title = screen.getByText('Vite \+ React') const editText = screen.getByText((content, _) => content.includes('Edit') && content.includes('save to test HMR')) const docsText = screen.getByText('Click on the Vite and React logos to learn more') expect(title).toBeInTheDocument() expect(editText).toBeInTheDocument() expect(docsText).toBeInTheDocument() }) })

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Is create-react-app Deprecated? What You Need to Know in 2025

    2 projects | dev.to | 11 May 2025
  • Advanced React SSR Techniques with Streaming and Dynamic Data

    4 projects | dev.to | 3 Jan 2025
  • Managing Static Assets in Public Directory vs Imports

    2 projects | dev.to | 19 Jul 2024
  • TypeScript SDK Development: A 5-year-old could follow this step-by-step ~ Part 3, Making Test Apps

    2 projects | dev.to | 25 Jun 2024
  • Series - Converting Large Codebase Project to Vite

    2 projects | dev.to | 24 May 2024

Did you know that TypeScript is
the 1st most popular programming language
based on number of references?