diff --git a/src/App.spec.tsx b/src/App.spec.tsx index 9b92840..d129857 100644 --- a/src/App.spec.tsx +++ b/src/App.spec.tsx @@ -1,11 +1,11 @@ import App from './App' -import { render, userEvent, screen } from './test/utils' +import { render, screen } from './test/utils' describe('app', () => { it('should increase count', async () => { - render() + const { user } = render() - userEvent.click(screen.getByRole('button', { name: /count is 0/i })) + user.click(screen.getByRole('button', { name: /count is 0/i })) await expect( screen.findByRole('button', { name: /count is 1/i }) diff --git a/src/test/utils.ts b/src/test/utils.ts deleted file mode 100644 index 2c5fa49..0000000 --- a/src/test/utils.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { cleanup, render } from '@testing-library/react' -import { afterEach } from 'vitest' - -afterEach(() => { - cleanup() -}) - -const customRender = (ui: React.ReactElement, options = {}) => - render(ui, { - // wrap provider(s) here if needed - wrapper: ({ children }) => children, - ...options, - }) - -export * from '@testing-library/react' -export { default as userEvent } from '@testing-library/user-event' - -export { customRender as render } diff --git a/src/test/utils.tsx b/src/test/utils.tsx new file mode 100644 index 0000000..df4afce --- /dev/null +++ b/src/test/utils.tsx @@ -0,0 +1,20 @@ +import { cleanup, render } from '@testing-library/react' +import userEvent from '@testing-library/user-event' +import { afterEach } from 'vitest' + +afterEach(() => { + cleanup() +}) + +const customRender = (ui: React.ReactElement, options = {}) => { + return { + user: userEvent.setup(), + ...render(ui, { + wrapper: ({ children }) => children, + ...options, + }), + } +} + +export * from '@testing-library/react' +export { customRender as render }