该项目具有客户端应用程序和服务器站点代码,并且在本地构建项目后,它将把所有构建好的资产(包括前端和后端内容)都放入build目录中,并且包含客户端需要使用的所有静态资产(所有测试用例都是也包括在那里)。
运行后续测试时,由于多个目录中存在重复的手动模拟,Jest将发出如下警告消息。
jest-haste-map: duplicate manual mock found:
Module name: fileMock
Duplicate Mock path: /Users/x/x/x/x/src/resources/webapp/static/__mocks__/fileMock.js
This warning is caused by two manual mock files with the same file name.
Jest will use the mock file found in:
/Users/x/x/x/x/src/resources/webapp/static/__mocks__/fileMock.js
Please delete one of the following two files:
/Users/x/x/x/x/build/classes/webapp/static/__mocks__/fileMock.js
/Users/x/x/x/x/src/resources/webapp/static/__mocks__/fileMock.js
Run Code Online (Sandbox Code Playgroud)
"jest": {
"modulePathIgnorePatterns": [
"<rootDir>/build"
]
}
Run Code Online (Sandbox Code Playgroud)
将build文件夹添加到文件modulePathIgnorePatterns内部package.json。
如果重复是由于相同的模拟,请将以下内容放入您的package.json文件中:
"jest": {
"modulePathIgnorePatterns": [
".*__mocks__.*"
]
}
Run Code Online (Sandbox Code Playgroud)
您可以在此处的配置 Jest中找到有关此配置选项的更多信息。
感谢上面评论中的@Denis。