You are assigning
myMethod to a mock function which doesn't do anything, not even your original
myMethod. When you are creating
jest.fn(), what it basically does is creating a dummy mock function which doesn't do anything. So when you call
wrapper.find('ChildComponent').props().myMethod(), it just call that function but not your
What you might want to do is to spy on your method instead.
jest.spyOn(ParentComponent.prototype, 'myMethod'); // ParentComponent.prototype.myMethod is now a mock function expect(ParentComponent.prototype.myMethod).toHaveBeenCalledTimes(1); // it works
- Jest - test method that passes to child component
- Jest Enzyme test a React component that returns null in render method
- Is there a way to unit test an innaccessible callback function that is called from a child React component using jest
- React - Where to unit test state change when parent component passes method as prop: parent or child component?
- How do I test that a child component is rendered?
- How to test child component method with Enzyme?
- mock useDispatch in jest and test the params with using that dispatch action in functional component
- How to test React state after calling a component method that updates state - using Enzyme
- Unit test method that calls clearInterval with Jest and Enzyme on React
- Jest test passes but .. has console message You are trying to access a property or method of the Jest environment after it has been torn down
- How to test a React component that has Router, Redux and two HOCs... with Jest and Enzyme?
- How to test state that has been lifted up from child to parent component in React?
- How to test a React component that uses context like in react-router 2.0 with Jest 0.8.x
- How test callback click in child component that was passed from parent component?
- Test that React prop method has been called with Jest
- Isolate child component in test - react-testing-library & Jest
- Test the state in parent component that was updated thru child component
- How to test a React component that renders a Redux-connected component as a child without providing mock Redux store?
- How to test a React component that update over time with Jest and Enzyme?
- Test React component that depends on a Promise with Jest
- jest test call of method that is not mocked
- How can I test if child React component was rendered based on a URL change using Jest and Enzyme
- How do I use jest to test a React component that imports a component that imports jQuery UI
- Cannot read property of null in jest test where child component is being mocked
- Getting '_axios.default.create is not a function' when trying to test a component that makes an axios call with Jest
- How do I test a Component that uses a StaticQuery with Jest
- How can I test a function of a function component that uses React.useState() using jest enzyme testing?
- Should I test if a "wrapper layout" component passes props to children components that were already tested?
- How to define propTypes for a Component that only passes props to a Child
- How to test child component method without Enzyme?
More Query from same tag
- Validation in react
- Styled Components in React app with dynamic text
- Load Json data from local file into Typescript variable in REACT
- Appsync Update and Delete mutation not working
- React Router -- history push state not refreshing with new state object
- why is my variable undefined in reactjs with web3
- How can i pass data from child component to parent component which in above second level by using function base in React?
- Access host variable from virtual machine
- How to split media queries under webpack config?
- Targeting nested object properties inside an parent object
- SpringBoot + WebFlux + Reactjs Server Sent Events onmessage not fire up
- How change the sender name of a mail with nodemailer?
- Passing websocket streaming data to child in reactJS
- Flask Session does not hold any value between Requests
- does not exist on type 'string'.ts(2339)
- Change header style for expanded Panel of Accordion in React Bootstrap
- react-datepicker includeTimes option
- Updating complicated Object with useState
- How to send props to reactjs when Redirect
- Call React.createElement with variable ReactClass name
- Bundler does not load automatically (No bundle URL present error)
- unable to access custom component property from parent component
- Where is the datepicker in material ui next?
- cannot setState in React app
- Place Material-ui icon inside circular progress indicator
- why do I get the error X is not iterable when setting state with the spread operator?
- redux doesn't update props immediately
- Rect Post request
- Passing data from Child functional component to parent - React/Typescript
- Uncaught Invariant Violation: Minified React error