vitest-react
v0.9.5
Published
🧪 Test utils setup for react/nextjs projects using Vitest with TypeScript
Downloads
2,452
Readme
🧪 vitest-react
Auto setup project to use Vitest with TypeScript + test-utils
🔖 Description
Tool to auto initialize vitest config for react/nextjs projects. Allow to use common test utils methods.
📦 Installation
# Install the package
$ npm install -D vitest-react
🚀 Usage
Just install the package and it will automatically create a vitest config file in your project root if needed.
Also you have some common test utils methods available:
/**
* You can import some pre-setup common methods in your test files.
*/
import {
render,
renderWithNextRouter, // mocked next router
renderWithProviders, // wrap component in providers
userEvent, // all from @testing-library/user-event
// All the @testing-library/react ones
screen,
waitFor,
// ...
}
/**
* You can also use methods from
* @testing-library/jest-dom automatically
*/
expect(element).toHaveClass('example-class')
expect(element).toBeVisible()
// ...
🤓 Happy Code
Created with Typescript! ⚡ and latin music 🎺🎵