A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://stackoverflow.com/questions/tagged/react-hooks-testing-library below:

Newest 'react-hooks-testing-library' Questions - Stack Overflow

0 votes

1 answer

274 views

testing-library/react-hooks calling a function that change the state

I tried everything but still for some reason the react state doesn't change, what is I am missing or what is the alternative approach? Code: export const useCounter = (): UseCounterResult => { ...

asked Feb 5, 2024 at 22:26

0 votes

2 answers

906 views

How can I test two different GET queries in the same React custom hook using react testing library and react-hooks?

I'm using a custom react hook to perform two GET operations using react query. The API is in a separate module and uses both getTestByUid() and getTestStatuses() inside useQuery. // TestHook.js import ...

asked May 30, 2023 at 22:57

1 vote

0 answers

397 views

react-hooks-testing-library: Context Provider, state change in child function act() error

I am using the React renderHook() function to call a custom hook. Internally in the custom hook, I call a function that executes axios, gets data and on success, dispatches a state change to a custom ...

asked May 2, 2023 at 17:02

0 votes

0 answers

300 views

How to test this window resize hook?

I've created a widget component that can be embedded on a webapp as a script. It is not embedded in an IFrame therefore lives inside the webapp's window object. This embedded component is responsive ...

asked Mar 8, 2023 at 12:09

1 vote

1 answer

346 views

React testing custom hook with window.url

I have a custom hook that downloads a file from an url, it works fine and now I trying to test its behaviour. const useFileDownload = ({ apiResponse, fileName }) => { const ref = useRef(null) ...

asked Feb 9, 2023 at 0:21

0 votes

0 answers

290 views

How can I test useEffect with async function in Jest?

I have this function inside a helper: export const useDAMProductImages = (imageId: string) => { const { app: { baseImgDomain }, } = getConfig(); const response: MutableRefObject<...

asked Feb 3, 2023 at 14:36

0 votes

0 answers

1k views

result.current.data is undefined when I declare renderHook into the test closure but works when it is defined outside of it

I'm trying to test a custom hook but for some reason I can't render the hook inside the test closure "it". This code works (I must use the rerender methods otherwise the result.current.data ...

asked Dec 28, 2022 at 11:13

1 vote

2 answers

3k views

TypeError: navigation.navigate is not a function in jest

Here is touchable element with navigation.navigate (react navigation 6.x), export default Home = ({ navigation }) => { .... return ( <TouchableOpacity testID={"...

asked Nov 23, 2022 at 5:01 Testing custom hooks react typescript

Im learning react testing and i have this hook i want to test but i have no idea how import { useState, useCallback } from 'react'; import axios from 'axios'; export const useFetch = () => { ...

asked Oct 14, 2022 at 2:00

-1 votes

1 answer

313 views

Handling state of select tag in dynamic input field react

I do not understand why the state is registered yet it does not have an effect to the intended value of beds. Here is the main component const options = ["1", "2", "3"]; ...

asked Sep 26, 2022 at 21:10

1 vote

0 answers

2k views

Vitest + MSW - Runtime request handler is not working

I'm trying to migrate the test framework of my app from Jest to Vitest (for multiple reasons) and I encounter an issue. With Jest, I was using runtime request handlers at multiple places of my app to ...

asked Sep 20, 2022 at 12:56

0 votes

2 answers

529 views

not able to install react-google-login

Trying to install "react-google-login" by using the command npm install react-google-login. It gives the following error : npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve ...

asked Aug 11, 2022 at 10:11

2 votes

1 answer

180 views

react page doesnt render when getting the data back from server

react won't work when rendering the page, but when i changed code in the vscode (added a line of console or comment one line out), the page is rendered. or when page is not rendered. when i hit ...

asked Jul 22, 2022 at 21:57 React Testing Library - mock offsetWidth, offsetLeft

I need your help on fixing the test case. I am trying to mock the document body offsetwidth, offsetLeft objects. In the resize method, I am trying to mock the newWidth which is calculating the mouse ...

asked Jul 10, 2022 at 6:28

4 votes

2 answers

8k views

What is the suitable type for renderHook in react-testing-library and TypeScript?

I wanna test a custom hook with react-testing-library therefore, I add this code into beforeEach: let renderedHook ; beforeEach(() => { renderedHook = renderHook(() => useFetch()); }); test('...

asked Jun 13, 2022 at 11:21

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4