-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetUpTest.tsx
33 lines (28 loc) · 961 Bytes
/
setUpTest.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import '@testing-library/jest-dom';
import { toHaveNoViolations } from 'jest-axe';
import React, { ReactElement, ReactNode } from 'react';
import { render as rtlRender } from '@testing-library/react';
import messagesNb from 'lib/translations/nb.json';
import { NextIntlClientProvider } from 'next-intl';
require('jest-fetch-mock').enableMocks();
jest.mock('next/router', () => ({
useRouter: jest.fn(),
}));
jest.mock('next/navigation', () => ({
useParams: jest.fn(),
}));
expect.extend(toHaveNoViolations);
function render(ui: ReactElement, { locale = 'nb', ...options } = {}) {
function Wrapper({ children }: { children: ReactNode }) {
return (
<NextIntlClientProvider locale={locale} messages={messagesNb}>
{children}
</NextIntlClientProvider>
);
}
return rtlRender(ui, { wrapper: Wrapper, ...options });
}
// re-export everything
export * from '@testing-library/react';
// override render method
export { render };