react-hooks-testing-library Questions
11
Currently Im using functional component with react hooks. But I'm unable to test the useState hook completely. Consider a scenario like, in useEffect hook I'm doing an API call and setting value in...
Guiana asked 14/7, 2019 at 8:29
2
Solved
I want to test a custom hook which was implemented as an helping function for code reuse with other hooks. It's calling useDispatch and useSelector in its implementation, along with saving data in ...
Riccio asked 22/12, 2019 at 7:39
3
Solved
I am having an issue setting up a unit test to determine that a function is called with the correct arguments. useAHook returns function foo which calls function bar. The code looks like this
//my...
Egret asked 5/6, 2019 at 14:31
1
There is an example on advanced-hooks#async doc.
I am confused about how does waitForNextUpdate works. I made two test cases to compare waitForNextUpdate and act() + jest.advanceTimersByTime().
ind...
Peripheral asked 15/11, 2021 at 6:5
2
I have quite complex and still growing application. We use react with hooks, context and other useful stuff. In general, testing react hooks with @testing-library/react-hooks is easy. Just from tim...
Kit asked 18/8, 2020 at 16:6
2
I have a custom hook that can have an optional ref passed to it as a property of an object that the hook takes as an argument:
export const useShortcuts = ({ ref }) => {
useEffect(() => {
...
Nadeen asked 4/8, 2019 at 21:4
1
Solved
So I'm pretty new to testing with react. I have a custom hook that I am calling inside a component. I am using the renderHook methods from react-hook-testing-library.
I need to test if the methods ...
Matos asked 13/1, 2021 at 14:11
1
I created a custom react hook that is supposed to handle all less important api requests, which i don't want to store in the redux state. Hook works fine but I have trouble testing it. My test setu...
Flaherty asked 14/8, 2019 at 13:33
1
Solved
Reducer
// src/reducers/FooReducer.js
export function FooReducer(state, action) {
switch (action.type) {
case 'update': {
return action.newState;
}
// ... other actions
default:
throw new Er...
Celin asked 10/12, 2019 at 21:14
1
Solved
I have the following hook :
const useBar = () => {
const [myFoo, setFoo] = useState(0);
const [myBar, setBar] = useState(0);
useEffect(() => {
setFoo(myFoo + 1);
console.log("setting ...
Nervine asked 18/7, 2019 at 11:57
1
I'm trying to test the following scenario:
A user with an expired token tries to access a resource he is not authorized
The resources returns a 401 error
The application updates a global state "i...
Fungible asked 3/6, 2019 at 12:34
1
© 2022 - 2024 — McMap. All rights reserved.