I'm currently making a react app with typescript, and I'm testing using react-testing-library. The app crashes with ReferenceError: jest is not defined
. All of my tests pass though.
Previously, everything was working. The only thing that has changed is I reorganized a few files.
Code:
import { FormProps } from "../containers";
const onChange = jest.fn(); // The problem
const history: any = jest.fn();
const location: any = jest.fn();
const match: any = jest.fn();
const TestProps: FormProps = {
onChange,
history,
location,
match,
};
export default TestProps;
jest
is defined as a global when tests are run usingJest
, but otherwise it doesn't exist and should never be used in code run in the app. – Mozellamozelle