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

jest单元格测试报错 #1229

Closed
lgf196 opened this issue Sep 22, 2021 · 10 comments
Closed

jest单元格测试报错 #1229

lgf196 opened this issue Sep 22, 2021 · 10 comments

Comments

@lgf196
Copy link

lgf196 commented Sep 22, 2021

我这边执行单元格报了如下的错误:
image

@mynetfan
Copy link
Collaborator

此文件当前代码并无这种用法。你是自己添加的代码吗?

@lgf196
Copy link
Author

lgf196 commented Sep 22, 2021

我的是这样的
image
image

此文件当前代码并无这种用法。你是自己添加的代码吗?

@lgf196
Copy link
Author

lgf196 commented Sep 22, 2021

此文件当前代码并无这种用法。你是自己添加的代码吗?

.env.preprod文件里面的代码是这样的:
NODE_ENV=production
VITE_APP_ANT=preprod
其它的环境类似

@mynetfan
Copy link
Collaborator

说的是你的src/utils/index.ts第六行

@lgf196
Copy link
Author

lgf196 commented Sep 22, 2021

说的是你的src/utils/index.ts第六行

image
这个就是我的until/index里面的代码,没问题哈,启动没问题,jest就报错

@mynetfan
Copy link
Collaborator

问题就出在第六行,这种写法没有通过测试,错误提示已经说得很明白了

@lgf196
Copy link
Author

lgf196 commented Sep 22, 2021

问题就出在第六行,这种写法没有通过测试,错误提示已经说得很明白了

我知道是这种写法的问题,但是我们获取环境变量不就是通过:import.meta.env.xx来的吧,是jest不支持import.meta,还是什么原因呢

@mynetfan
Copy link
Collaborator

vitejs/vite#1955

@lgf196
Copy link
Author

lgf196 commented Sep 22, 2021

vitejs/vite#1955

这篇文章看了的,说是jest暂时不支持,不过还是感谢你

@Free-Qi
Copy link

Free-Qi commented May 11, 2022

能问下,这个框架的jest如何使用么

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

4 participants