Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/chempogonzalez/vitest-react

πŸ§ͺ Test utils setup for react/nextjs projects using Vitest
https://github.com/chempogonzalez/vitest-react

Last synced: 23 days ago
JSON representation

πŸ§ͺ Test utils setup for react/nextjs projects using Vitest

Awesome Lists containing this project

README

        

# πŸ§ͺ vitest-react [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)

> 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
```zsh
# 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:
```ts
/**
* 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 🎺🎡