English 中文(简体)
如何处理项目发现的重复人工模拟
原标题:How to handle duplicated manual mock found in the project
  • 时间:2018-09-20 02:11:51
  •  标签:
  • jestjs

The project has both client app and server site code and once the project is built locally it will put all the built assets both front-end and back-end stuff into build directory and it contains all statics assets client needs to use (all test cases are also included there).

进行后续测试 由于在多个名录中存在着人工模拟,因此,最小线将产生如下的警告信息。

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
最佳回答
问题回答

我使用字体并发出以下警告:

jest-haste-map: duplicate manual mock found: createDocumentInput
  The following files share their name; please delete one of them:
    * <rootDir>/dist/modules/__mocks__/xxx.js
    * <rootDir>/src/modules/__mocks__/yyy.ts

我在<代码>上添加了以下“不适用”的内容:

{
...
"exclude": [
    "dist",
    "**/__mocks__/*",
    "**/node_modules/*",
    "build",
    "src/**/*.test.ts",
    "src/**/*.test.tsx"
  ]
}





相关问题
How to change return value of mocked class method

I have a mocked class of a node module and its method as below, and test case to test case I need to change the methodOne returning value. jest.mock("module_name", () => { return { ...

Why LD SDK Jest Test MockFlags Returning Undefined

So I have a component that checks a flag and based on if the flag returns true or false, we do something with it. The issue I have is when I am mocking according to LD documentation, the flag is ...

how to mock function in react js?

I am trying to do/write unit test of below function. import { getDetail } from "./api"; export const fetchDetail = async (jobNumber) => { try { const response = await getDetail(...

热门标签