-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-utils.js
35 lines (30 loc) · 948 Bytes
/
test-utils.js
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
34
35
import React from 'react';
import { render } from '@testing-library/react';
import '@testing-library/jest-dom';
import { RecoilRoot } from 'recoil';
import { transitions, positions, Provider as AlertProvider } from 'react-alert';
import AlertTemplate from 'react-alert-template-basic';
// optional configuration
const options = {
// you can also just use 'bottom center'
position: positions.BOTTOM_CENTER,
timeout: 5000,
offset: '30px',
// you can also just use 'scale'
transition: transitions.SCALE,
};
const renderWithProviders = ({ children }) => {
return (
<RecoilRoot>
<AlertProvider template={AlertTemplate} {...options}>
{children}
</AlertProvider>
</RecoilRoot>
);
};
const customRender = (ui, options) =>
render(ui, { wrapper: renderWithProviders, ...options });
// re-export everything
export * from '@testing-library/react';
// override render method
export { customRender as render };