diff --git a/jest.config.mjs b/jest.config.mjs index fbad9f2..19c3981 100644 --- a/jest.config.mjs +++ b/jest.config.mjs @@ -1,4 +1,6 @@ import nextJest from "next/jest.js" +import { createRequire } from "module" +const require = createRequire(import.meta.url) const createJestConfig = nextJest({ // Provide the path to your Next.js app to load next.config.js and .env files in your test environment @@ -12,6 +14,9 @@ const config = { // setupFilesAfterEnv: ['/jest.setup.js'], testEnvironment: "jest-environment-jsdom", transformIgnorePatterns: ["node_modules/jose/dist/browser/index.js"], + moduleNameMapper: { + "^jose": require.resolve("jose"), + }, } // createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async diff --git a/src/__tests__/jest/MainLayout.test.tsx b/src/__tests__/jest/MainLayout.test.tsx deleted file mode 100644 index 55d8d6c..0000000 --- a/src/__tests__/jest/MainLayout.test.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import "@testing-library/jest-dom" -import { render, screen } from "@testing-library/react" -// components -import MainLayout from "src/components/MainLayout" - -jest.mock("next/router", () => require("next-router-mock")) - -describe("test MainLayout", () => { - it("should render 404 page", async () => { - render( - -
hello world
-
- ) - expect(screen.getByRole("button", { name: /Go to login/i })) - expect(screen.getByText(/page not found/i)) - expect(screen.queryByText(/hello world/i)).not.toBeInTheDocument() - }) -})