相关疑难解决方法(0)

Nextjs 和 Jest 变换/transformIgnorePatterns 不适用于 esm 模块

我对此进行了大量研究,并找到了相当多的解决方案。我已经找到了一种解决方法,并且希望能够正常transform工作transformIgnorePatterns。然而,我唯一能做的似乎就是在我的__mocks__文件夹中手动添加一些模拟模块。

不确定这是否是由于使用Nextjswith引起Jest的?

这是我的jest.config.js

const nextJest = require("next/jest");

const esModules = ["react-markdown", "rehype-raw", "remark-gfm"].join("|");

const createJestConfig = nextJest({
  // Provide the path to your Next.js app to load next.config.js and .env files in your test environment
  dir: "./",
});

// Add any custom config to be passed to Jest
const customJestConfig = {
  setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
  moduleNameMapper: {
    // Handle module aliases (this will be automatically configured for you soon)
    "^@/components/(.*)$": …
Run Code Online (Sandbox Code Playgroud)

reactjs jestjs next.js

8
推荐指数
1
解决办法
4527
查看次数

标签 统计

jestjs ×1

next.js ×1

reactjs ×1