Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] umi simple app,无法运行 umi g jest 配置的测试 #12733

Open
tanukihee opened this issue Oct 11, 2024 · 1 comment
Open

[Bug] umi simple app,无法运行 umi g jest 配置的测试 #12733

tanukihee opened this issue Oct 11, 2024 · 1 comment

Comments

@tanukihee
Copy link

What happens?

新建 umi simple app 后,使用 umi g jest 增加 jest 配置,无法运行 test。

Mini Showcase Repository(REQUIRED)

Please provide a minimal reproduction then upload to your GitHub. 请提供 最小重现,并上传到你的 GitHub 仓库

https://stackblitz.com/edit/umi-edm1pg

How To Reproduce

Steps to reproduce the behavior:

  1. 使用 pnpm create umi 生成 Simple App
  2. 使用 pnpm umi g jest 配置使用 jest
  3. 使用 pnpm test 运行测试

Expected behavior

  1. 测试运行通过

Actual behavior

> @ test /home/projects/vitejs-vite-edm1pg
> cross-env TS_NODE_TRANSPILE_ONLY=yes jest --passWithNoTests

Error: Jest: Failed to parse the TypeScript config file /home/projects/vitejs-vite-edm1pg/jest.config.ts
  TSError: ⨯ Unable to compile TypeScript:
error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.

    at readConfigFileAndSetRootDir (/home/projects/vitejs-vite-edm1pg/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/jest-config/build/readConfigFileAndSetRootDir.js:116:13)
    at async readInitialOptions (/home/projects/vitejs-vite-edm1pg/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/jest-config/build/index.js:403:13)
    at async readConfig (/home/projects/vitejs-vite-edm1pg/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/jest-config/build/index.js:147:48)
    at async readConfigs (/home/projects/vitejs-vite-edm1pg/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/jest-config/build/index.js:424:26)
    at async runCLI (/home/projects/vitejs-vite-edm1pg/node_modules/.pnpm/@[email protected][email protected]/node_modules/@jest/core/build/cli/index.js:151:59)
    at async Object.run (/home/projects/vitejs-vite-edm1pg/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/jest-cli/build/run.js:130:37)
 ELIFECYCLE  Test failed. See above for more details.

Temporary workaround:

  1. 已确认 src/.umi/tsconfig.json 中已设置 "module": "esnext",,注释掉 "moduleResolution": "bundler", 后,测试可正常运行,但此时所有模块导出均错误。

Context

  • Umi Version: 4.3.25
  • Node Version: 18.2.3
  • Platform: GNU/Linux
@lingjieding
Copy link

cypress-io/cypress#27731 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants