You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// index.tsx
import Head from "next/head";
import Image from "next/image";
import axios from "axios";
import styles from "@/pages/index.module.css";
console.log({ axios });
index.test.tsx
import { render, screen } from "@testing-library/react";
import Home from "@/pages/index";
jest.mock("axios");
describe("Home", () => {
it("renders a heading", () => {
render(<Home />);
const heading = screen.getByRole("heading", {
name: /welcome to next\.js!/i,
});
expect(heading).toBeInTheDocument();
});
});
Expected Behavior
Expect the console log to log a mocked axios but instead returns actual axios
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
vercel
locked as resolved and limited conversation to collaborators
Feb 4, 2022
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
SWCRelated to minification/transpilation in Next.js.
What version of Next.js are you using?
latest
What version of Node.js are you using?
16.1.0
What browser are you using?
n/a
What operating system are you using?
macOS
How are you deploying your application?
n/a
Describe the Bug
I cloned https://github.com/vercel/next.js/tree/canary/examples/with-jest and simply added
Expected Behavior
Expect the console log to log a mocked axios but instead returns actual axios
To Reproduce
Add any
jest.mock
to anything in https://github.com/vercel/next.js/tree/canary/examples/with-jestThe text was updated successfully, but these errors were encountered: