2023-06-07 02:37:10 +00:00
|
|
|
import { cleanup, render } from '@testing-library/react';
|
|
|
|
import { afterEach } from 'vitest';
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
cleanup();
|
|
|
|
document.body.innerHTML = '';
|
|
|
|
});
|
|
|
|
|
|
|
|
function customRender(ui: React.ReactElement, options = {}) {
|
|
|
|
return 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';
|
|
|
|
// override render export
|
|
|
|
export { customRender as render };
|
2023-05-25 02:40:08 +00:00
|
|
|
|
|
|
|
export const sleep = async (timeout = 0) => {
|
2023-06-07 02:37:10 +00:00
|
|
|
return new Promise((resolve) => {
|
|
|
|
setTimeout(resolve, timeout);
|
2023-05-25 02:40:08 +00:00
|
|
|
});
|
|
|
|
};
|