我得到这个错误与Jest -文件路径是不同的,这让我想知道为什么这是抱怨?我想我被告知,index.js是一个重复的名字,即使模拟是在不同的道路上--当然不是?我在测试文件中使用这两种方法中的模拟--我不能使用带有jest的索引文件吗?!
jest-haste-map: duplicate manual mock found: index
The following files share their name; please delete one of them:
* <rootDir>/dist/Actions/SendDistributions/__mocks__/index.js
* <rootDir>/dist/Actions/SendQualifications/__mocks__/index.js
jest-haste-map: duplicate manual mock found: index
The following files share their name; please delete one of them:
* <rootDir>/dist/Actions/SendQualifications/__mocks__/index.js
* <rootDir>/dist/Actions/SendLeads/__mocks__/index.js发布于 2022-06-23 07:26:51
要删除警告,您需要将以下内容添加到jest配置- jest.config.js或package.json等。
jest.config.js
module.exports = {
...,
modulePathIgnorePatterns: ["<rootDir>/.*/__mocks__"]
};或
package.json
"jest": {
"modulePathIgnorePatterns": [
"<rootDir>/.*/__mocks__"
]
}然后,您可以继续使用模拟的结构化方式,您已经展示了。
https://stackoverflow.com/questions/67420028
复制相似问题