How to Mock WrappedFormUtils
See original GitHub issueWhat problem does this feature solve?
Hi, we have a form that is created with Form.create. We then have a component called ContractConditions that is used within that form that contains further FormItems.
The component gets passed the form like this:
<ContractConditions form={this.props.form} />
This works, but I am unsure of how to mock the WrappedFormUtils when trying to test ContractConditions? ContractConditions expects the ‘form’ prop to be set up in the unit test. Do you have examples of how to mock a WrappedFormUtils using Jest and Enzyme?
thanks
What does the proposed API look like?
No api required
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Mocking refs in React function component - Stack Overflow
Here is my unit test strategy, use jest.spyOn method spy on the useRef hook. index.tsx : import React from 'react'; export const Comp ......
Read more >React 单元测试实践- 掘金
一般来说如果报错部分其实和测试无关,可以直接mock 掉,如果比较重要就建议 ... function getForm() { let form: WrappedFormUtils<any>; const Fake ...
Read more >Antd form typescript - Weebly
TypeScript is a javascript superset that adds many useful features to javascript: Type annotations and compile the type of inference type Erase Interfaces ......
Read more >编写单元测试,规范很重要
... 写在render方法里面, 需要在table里mock进去不同的数据, 也增加了编码工作。 ... export const filter = (form: WrappedFormUtils) => (e: React.
Read more >React单元测试实践 - CSDN
一般来说如果报错部分其实和测试无关,可以直接mock 掉,如果比较重要就建议补全对应 ... let form: WrappedFormUtils<any>; const Fake = Form.create()((props: any) ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@benjycui 打扰一下,我在测试由Form.create()封装过的myComponent遇到这样的困惑: 因为myComponent组件内需要用到form的方法(如getFieldDecorator,validateFieldsAndScroll),我直接对myComponent进行测试的话,是需要对props.form内需要用到的进行模拟mock吗?可否举个例子,非常感谢
I test
WrappedFormUtils
like this: