• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home » Resolved: Jest test fails on a react component which uses react-hooks-form with sharing refs

Resolved: Jest test fails on a react component which uses react-hooks-form with sharing refs

0
By Isaac Tonny on 16/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

Here is the abstract version of my component
Test case
Executing this test throws an error as given below.
I tried to mock the ref as function but it didn’t help. It would be great if anyone can throw some insights.

Answer:

register is a function that returns props the input needs. You are mocking the register function, but it still needs to return everything the component is consuming or passing on. Specifically it seems you need to return a ref function for what is returned by the useFormContext hook.
Example:

If you have better answer, please add a comment about this, thank you!

javascript react-hook-form react-hooks reactjs
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: PostgreSQL resample 1 minute OHLCV candle data into 5 minute OHLCV candle data

27/03/2023

Resolved: How do I navigate a table without any easily accessible distinctions?

27/03/2023

Resolved: Can a pod make itself unavailable temporarily in kubernetes?

27/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.