jest.mock("../Contexts/UserContext"); jest.mock("../../services/superset"); import { render, screen, waitFor } from "@testing-library/react"; import { BrowserRouter } from "react-router-dom"; import addSnapshotSerializer from "../../utils/snapshot"; import { TEST_AUTH_OBJECT_FISKER } from "../../utils/testing"; import { setToken, UserProvider } from "../Contexts/UserContext"; import SideMenu from "./SideMenu"; const renderMenu = async () => { const { container } = render( ); await waitFor(() => {}); return container; }; describe("SideMenu", () => { beforeAll(() => { addSnapshotSerializer(expect); }); it("Unauthenticated", async () => { setToken({ idToken: { jwtToken: null } }); const container = await renderMenu(); expect(container).toMatchSnapshot(); }); it("Authenticated", async () => { setToken(TEST_AUTH_OBJECT_FISKER); const container = await renderMenu(); await waitFor(() => { expect(screen.getByText("Datascope")).toBeInTheDocument(); }); expect(container).toMatchSnapshot(); }); });