score:11
Accepted answer
The suggestion I've seen in a few places is to test the non-connected component, as opposed to the connected version. So, verify that when you pass in specific props to your component you get the expected rendered output, and verify that when you pass in a state with a certain shape your mapStateToProps()
returns the expected pieces. Then you can expect that they should both work correctly when put together.
Source: stackoverflow.com
Related Query
- How can I write a unit test for a react component that calls reduxjs's mapStateToProps?
- How can I mock multiple get axios request in Jest unit test for an async action that calls a few more async actions?
- How to write unit test for function that calls React.UseEffect in it ( code included )
- React & Jest: How to write a test for a component that depends on external function
- How to TEST async calls made in componentDidMount that set the state of React Component
- How to unit test a React component that renders after fetch has finished?
- How can I unit test parent react components that call methods on children
- How can I test css properties for a React component using react-testing-library?
- How can we write a click handler for a Stateless Function Component in React JS
- How do I test a React component that calls a function on its parent, which changes props on the component?
- How do I write a test for a component that uses React.cloneElement?
- React Test Question: Write a react component that create a list of seven days of week and we can delete any random day of the week on click on it?
- How to write unit test for custom select in React with out test id defined for select or option tag
- How can I write a Jest test in React to check if a component has a CSS class?
- How to add unit test for a function that calls a function received in props
- How to write test for the HTML element being passed as a prop to a component a and a function is being called from that
- How to write unit test for Material UI slider? "Error: Cannot read property 'addEventListener' of null" thrown when attempting to render component
- How to unit test react hooks component that fetches data in useEffect using Enzyme?
- How can I test react component that fetches the data from firestore?
- How can I write a react component that has dependent props in TypeScript?
- How do I mimic props available = TRUE in my unit test so I can test my react component in isolation
- How to write a test case for a simple React component using Jest and Enzyme
- How can I write React component that returns a class component as a functional component?
- React snapshot test with Jest, how can a child component calls a function from parent component?
- How can I unit test my react component prop API
- How to write test case coverage in Jest and Enzyme for indexOf used inside React Component
- How can I write an adapter for my React Final Form component with Typescript?
- How to write unit test for render component
- write unit test for event handlers that updates some state in react using jest and enzyme
- How to write a Jest-enzyme test case for code in React useEffect whose dependencies are updated in its child component
More Query from same tag
- Create input change Event in a function
- Immutable-JS: Merge a List of Maps by key
- Cannot find module 'internal/fs' not working as per the existing solutions
- How to display only part of a background image: linear gradient?
- React - Setting up Route for different set of pages
- How to add a button depending on number of child elements?
- React Hook Form - Errors not working for multiple forms on a single page for react hook form v7.5.2
- Removing items from state by timer
- How to change apply setState when onChange happend?
- ReactJS - Lightbox component Issue
- Inserting button from HTML <script> tag in React.js
- React/Redux animations based on actions
- Trying to write a function that can accept an optional parameter and based on it's type, filter and return an icon
- React: Cannot read property 'setState' of undefined
- Axios then, catch are not called
- Functional component props/state/store not updated in function - what's a viable alternative?
- React re render after each step of bubble sort algo
- react-native: command not found
- how to "delete the textarea by clicking delete button" in reactjs
- TypeError: Cannot read property 'map' of undefined - react js
- React wont be loaded with Webpack 5, but in 4
- React: Get month name instead of number
- react js toggle problem when I visit from mobile
- How to update component from non-React environment?
- Cannot set the state of a unmounted component in react
- Onclick of Steps in timeline component in react should be set as active and change color of timeline
- CSS Grid layout when mapping through elements
- How would you use componentDidUpdate to update something without having to refresh the page?
- Throwing 404 Error with message "Cannot POST /api/users/register"
- UI does not update when the React component re-renders