Skip to content

Commit

Permalink
✅(frontend) fix failing test
Browse files Browse the repository at this point in the history
Modification of the create doc button added the need for useRouter to be mounted during testing.
This adds a mock function to allow for testing.
  • Loading branch information
Arnaud Robin committed Sep 22, 2024
1 parent b0b759c commit 958de0b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/frontend/apps/impress/src/__tests__/pages.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,23 @@ import { AppWrapper } from '@/tests/utils';

import Page from '../pages';

// Mock the useRouter hook
jest.mock('next/navigation', () => ({
useRouter() {
return {
push: jest.fn(),
};
},
}));

describe('Page', () => {
it('checks Page rendering', () => {
render(<Page />, { wrapper: AppWrapper });

expect(
screen.getByRole('button', {
name: /Create a new document/i,
}),
})
).toBeInTheDocument();
});
});

0 comments on commit 958de0b

Please sign in to comment.