You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
904 B
TypeScript
28 lines
904 B
TypeScript
/* eslint-disable import/no-extraneous-dependencies */
|
|
import { render, RenderOptions } from '@testing-library/react';
|
|
import { AnimatePresence, MotionGlobalConfig } from 'framer-motion';
|
|
import { ReactElement, ReactNode } from 'react';
|
|
import { SessionTheme } from '../../themes/SessionTheme';
|
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
|
|
const Providers = ({ children }: { children: ReactNode }) => {
|
|
MotionGlobalConfig.skipAnimations = false;
|
|
|
|
return (
|
|
<SessionTheme>
|
|
<AnimatePresence>
|
|
<ErrorBoundary
|
|
fallback={<>{`Failed to render a component!\n\t${JSON.stringify(children)}`}</>}
|
|
>
|
|
{children}
|
|
</ErrorBoundary>
|
|
</AnimatePresence>
|
|
</SessionTheme>
|
|
);
|
|
};
|
|
|
|
const renderComponent = (ui: ReactElement, options?: Omit<RenderOptions, 'wrapper'>) =>
|
|
render(ui, { wrapper: Providers, ...options });
|
|
|
|
export { renderComponent };
|