const isInitialMount = useRef(true);
useEffect(() => {
if (isInitialMount.current) {
isInitialMount.current = false;
} else {
// Your useEffect code here to be run on update
}
});
import App from "./app.jsx";
import axios from "axios";
jest.mock("axios");
beforeEach(() => {
axios.create = jest.fn(() => axios);
axios.get.mockImplementation((url) => {
return Promise.resolve({
data: [{ id: 1, name: "books" }],
});
});
});
test("should display app", async () => {
render(<App />);
expect(await screen.findByText("books")).toBeInTheDocument();
});