简体   繁体   English

Jest 不会清除缓存

[英]Jest won't clear cache

Jest is running old, outdated, commented out piece of code even after clearing it's cache.即使在清除缓存后,Jest 仍在运行旧的、过时的、注释掉的代码。

It's almost like it's stuck in the past and i've ran the jest --clearCache command but this doesn't seem to solve this issue.它几乎就像它停留在过去,我已经运行了jest --clearCache命令,但这似乎并没有解决这个问题。 if i comment out a test block, our even delete the test file, the test still runs.如果我注释掉一个测试块,我们甚至删除测试文件,测试仍然运行。 which is super super weird.这太奇怪了。

This is what my script looks like:这是我的脚本的样子:

 "test": "jest  --detectOpenHandles --watchAll --forceExit",

It appears you might have jest installed globally and locally (in the project).看来您可能已经在全球本地(在项目中)开玩笑地安装了。 So when you run jest --clearCache you are running it on the global installation of jest but in a package.json script it will call the jest local to the project.因此,当您运行jest --clearCache时,您是在 jest 的全局安装上运行它,但在package.json脚本中,它将调用项目本地的 jest。 This means you have two caches (one gloabal and one local) and are simply trying to delete the wrong one.这意味着您有两个缓存(一个全局缓存和一个本地缓存)并且只是试图删除错误的缓存。

In order to delete the projects cache you need to run:为了删除您需要运行的项目缓存:

npm run jest --clearCache
// or if using yarn
yarn jest --clearCache

also, (to address your comment) you can check where the cache directory is with:另外,(为了解决您的评论)您可以检查缓存目录的位置:

jest --showConfig | grep cacheDir
// or in the project
npm run jest --showConfig | grep cacheDir

then delete the folder it returns.然后删除它返回的文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM