T
TanStack3y ago
like-gold

enabled not working on testing

I am trying to test a component that relies on a useQuery hook. For other tests this works fine, however for the component that has the enabled flag set I don't get any data from the useQuery hook and also isLoading stays true. The strange thing is that when I log the enabled value it is logged as true but the test doesn't pass. If I however uncomment the enabled flag my test passes 🤷🏼‍♂️ See printscreen. Is there anything special I need to do when enabled flag is set to make my test pass? It's like in the test after enabled is true there is no more render anymore so I don't get the data this is my test
const { findByText } = render(
<MonitorPeak setShowFluvius={jest.fn()} showFluvius={showState.data} />,
)

await findByText(/BasicMonitoringScreen.consumptionPeak/)
const { findByText } = render(
<MonitorPeak setShowFluvius={jest.fn()} showFluvius={showState.data} />,
)

await findByText(/BasicMonitoringScreen.consumptionPeak/)
and see screenshot of my useQueryhook
No description
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?