React Testing Library setup for Vitest in ApiTree projects.
npm install @apitree.cz/testing-library``bash`
pnpm add --save-dev @apitree.cz/testing-library @testing-library/react vitest
In a monorepo, install and use the package in each workspace.
1. Setup Vitest for React with @apitree.cz/vitest-config.
2. Create tests/setup.ts:
`typescript`
import '@apitree.cz/testing-library/setup';
3. Create test renderers in tests/testing-library.ts
`typescript jsx
import { createRenderers } from '@apitree.cz/testing-library';
export * from '@testing-library/react';
export const { render, renderHook } = createRenderers();
`
> See CreateRenderersProps for createRenderers props reference.
4. Write your tests in tests directory and run them with vitest --run command.
> Use tests/testing-library.ts` for importing Testing Library utilities.