如何处理项目中发现的重复手动模拟

问题描述 投票:0回答:1

该项目同时具有客户端应用程序和服务器站点代码,一旦项目在本地构建,它将把所有构建的资产(前端和后端内容)放入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
jestjs
1个回答
4
投票
"jest": {
    "modulePathIgnorePatterns": [
        "<rootDir>/build"
    ]
}

build文件夹添加到modulePathIgnorePatterns文件中的package.json中。

© www.soinside.com 2019 - 2024. All rights reserved.