How to test a react component that is dependent on useContext hook?
I have a component that uses useContext
and then its output is dependent on the value in the context. A simple example:
I have a component that uses useContext
and then its output is dependent on the value in the context. A simple example:
I am using the NumericInput and it works fine when I run the application on my device.
For testing I use jest and react-test-renderer. It should be simple to test, however I have a hard time finding the proper example. I have tried to do something like that (in general I keep the functions in separate files):
I’m writing tests for my react page but my page uses an isLoading in its state, when loading the page renders ‘Loading’, when loaded but no data (from the fetch request) is renders ‘No data found’ and when loaded with data (from the fetch request) is loads the welcome page.