Added CypressStrictMode

This commit is contained in:
2022-08-15 11:51:40 +02:00
parent c0a0ea66a6
commit e20fea679a
4 changed files with 24 additions and 4 deletions

View File

@@ -0,0 +1,16 @@
import React, { FunctionComponent, ReactNode } from "react";
type Props = { children?: ReactNode };
/**
* React StrictMode that disables itself when detected to be running in Cypress
*/
export const CypressStrictMode: FunctionComponent<Props> = ({ children }) => {
const isInCypress = (window as any).Cypress;
if (isInCypress) {
return <>{children}</>;
} else {
return <React.StrictMode>{children}</React.StrictMode>;
}
};