[英]Jest.config settings modulePathIgnorePatterns and testPathIgnorePatterns aren't having any effect
I'm running tests in a node
app using jest
.我正在使用jest
在node
应用程序中运行测试。 I can get tests running properly, but I can't seem to tell jest
to ignore directories.我可以让测试正常运行,但我似乎无法告诉jest
忽略目录。 For example, when I try to test a specific file convertExistingImages.ts
with the command: npm test convertExistingImages
I get a response in my terminal of:例如,当我尝试使用以下命令测试特定文件convertExistingImages.ts
时: npm test convertExistingImages
我在终端中收到以下响应:
> mfa-bot-2022@1.0.0 test
> jest
FAIL dist/utils/maintenance.ts/convertExistingImages.test.js
● Test suite failed to run
Your test suite must contain at least one test.
(...)
FAIL src/utils/maintenance/convertExistingImages.test.ts
● Test suite failed to run
(...)
As you can see, a duplicate file in my /dist
folder is also being tested, which I don't want.如您所见,我的/dist
文件夹中的重复文件也在测试中,这是我不想要的。
I've tried updating my jest.config.ts
file as follows:我试过按如下方式更新我的jest.config.ts
文件:
module.exports = {
"preset": "@shelf/jest-mongodb",
"modulePathIgnorePatterns": ["/build/"],
"testPathIgnorePatterns": ["/node_modules/", "/build/"]
}
But the modulePathIgnorePatterns
and testPathIgnorePatterns
settings aren't having any effect.但是modulePathIgnorePatterns
和testPathIgnorePatterns
设置没有任何效果。
Can anyone tell me what I'm doing wrong?谁能告诉我我做错了什么?
You configured it to ignore the build
folder but your conflict is in the dist
folder.您将其配置为忽略build
文件夹,但您的冲突在dist
文件夹中。 Change build
to dist
in your ignore settings.在您的忽略设置中将build
更改为dist
。
You can read more about this config on the Jest site here .您可以在此处的 Jest 站点上阅读有关此配置的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.