Replace rendering with events with react testing library by vitest-browser-react

This commit is contained in:
Alejandro Celaya
2026-08-16 20:32:05 +02:00
parent 260bdb260c
commit 7b9f084f9c
8 changed files with 41 additions and 37 deletions

View File

@@ -4,6 +4,7 @@ import { render as testingLibRender } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import type { PropsWithChildren, ReactElement } from 'react';
import { Provider } from 'react-redux';
import type { RenderOptions as VitestRenderOptions } from 'vitest-browser-react';
import { render as vitestRender } from 'vitest-browser-react';
import { userEvent } from 'vitest/browser';
import { ContainerProvider } from '../../src/container/context';
@@ -12,9 +13,9 @@ import { setUpStore } from '../../src/store';
export const render = vitestRender;
export const renderWithEvents = (element: ReactElement, options?: RenderOptions) => ({
export const renderWithEvents = async (element: ReactElement, options?: VitestRenderOptions) => ({
user: userEvent.setup(),
...testingLibRender(element, options),
...(await render(element, options)),
});
export type RenderOptionsWithState = Omit<RenderOptions, 'wrapper'> & {
@@ -48,6 +49,7 @@ export const renderWithStore = (
return {
store,
...renderWithEvents(element, { ...options, wrapper: Wrapper }),
user: userEvent.setup(),
...testingLibRender(element, { ...options, wrapper: Wrapper }),
};
};