mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-10-17 03:04:08 +00:00
Replace rendering with events with react testing library by vitest-browser-react
This commit is contained in:
@@ -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 }),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user