Skip to content

Instantly share code, notes, and snippets.

@SebastianCB-dev
Last active November 3, 2023 01:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SebastianCB-dev/77975b0f6f4e625d08112de7b5b2a1c1 to your computer and use it in GitHub Desktop.
Save SebastianCB-dev/77975b0f6f4e625d08112de7b5b2a1c1 to your computer and use it in GitHub Desktop.
This is a Gist to configure testing in React + Vite

Step to install testing libraries in React JS.

This has to be used in project with React + Vite

  1. Installation
pnpm install vitest happy-dom @testing-library/react @testing-library/user-event --save-dev
  1. Go to file vite.config.ts and add this code
/// <reference types="vite/client" />

export default defineConfig({
  plugins: [react()],
  test: {
    environment: 'happy-dom'
  }
})
  1. Go to file package.json and add this code
"scripts": {
    "test": "vitest"
  },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment