Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
djhi committed Jan 9, 2025
1 parent 16a612a commit 528618b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/react-admin/src/Admin.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { render, screen } from '@testing-library/react';
import { fireEvent, render, screen } from '@testing-library/react';

import { Basic, InsideRouter, SubPath, DefaultError } from './Admin.stories';

Expand All @@ -25,7 +25,7 @@ describe('<Admin>', () => {

it('works when mounted in a subPath', async () => {
render(<SubPath />);
screen.getByText('Go to admin').click();
fireEvent.click(await screen.findByText('Go to admin'));
await screen.findByText('Post List');
screen.getAllByText('Comments')[0].click();
await screen.findByText('Comment List');
Expand Down
7 changes: 7 additions & 0 deletions test-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ global.Request = Request;

/** Mock scrollTo as it is not supported by JSDOM */
global.scrollTo = jest.fn();

/** Mock TextEncoder as it is not supported by JSDOM */
if (!global.TextEncoder || !global.TextDecoder) {
const { TextDecoder, TextEncoder } = require('node:util');
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;
}

0 comments on commit 528618b

Please sign in to comment.