找不到React'使用第三方React ui lib -vite+预先反应
我在这个Vite启动的存储库中面临这个问题。
https://github.com/vicainelli/vicainelli/vite-starter
我正在使用vite + preactct + vitest +测试库
如果我正在测试代码库中的任何代码,则可以正常工作,但是如果测试与使用外部库中另一个组件的某些组件运行,则我会遇到此错误。
⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯
FAIL src/components/Button.test.js [ src/components/Button.test.js ]
❯ Object.<anonymous> node_modules/@mantine/styles/cjs/theme/MantineProvider.js:5:13
Test Files 1 failed | 1 passed (2)
Tests 2 passed (2)
Error: Cannot find module 'react'
Require stack:
- /home/runner/work/vite-starter/vite-starter/node_modules/@mantine/styles/cjs/theme/MantineProvider.js
- /home/runner/work/vite-starter/vite-starter/node_modules/@mantine/styles/cjs/index.js
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
这类似于这个问题紧凑,所以,我不知道我在做什么错。
I'm facing this issue in this Vite started repository.
https://github.com/vicainelli/vite-starter
I'm using Vite + Preact + Vitest + Testing Library
If I'm testing any code inside the codebase, it works fine, but If the test runs against some component that uses another component from an external library, I'm getting this error.
⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯
FAIL src/components/Button.test.js [ src/components/Button.test.js ]
❯ Object.<anonymous> node_modules/@mantine/styles/cjs/theme/MantineProvider.js:5:13
Test Files 1 failed | 1 passed (2)
Tests 2 passed (2)
Error: Cannot find module 'react'
Require stack:
- /home/runner/work/vite-starter/vite-starter/node_modules/@mantine/styles/cjs/theme/MantineProvider.js
- /home/runner/work/vite-starter/vite-starter/node_modules/@mantine/styles/cjs/index.js
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
This is something similar to this issue, but I'm already using preact/compact, so, I have no idea what I'm doing wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要运行以下命令:
似乎 Vitest 无法有效地使用别名。
You'll want to run the following:
Seems like Vitest cannot effectively alias.