score:2
Accepted answer
could be something like this. you should test you wrapper to render wrapped component with its props. also test your functions that update state.
const bar = props => <span />
const test = container(bar)
const wrapper = shallow(<test prop1={1} prop2={2}>)
const bar = wrapper.find(bar)
expect(bar).to.have.length(1)
expect(bar.props()).contains({ prop1: 1, prop2: 2})
bar.props().showmodal()
expect(wrapper.state().showmodal).to.be(true)
Source: stackoverflow.com
Related Query
- How should I unit test this React Component?
- How to unit test React Component shouldComponentUpdate method
- How to unit test a style of a React Component using Jest.js?
- How can I write a unit test for a react component that calls reduxjs's mapStateToProps?
- How to unit test a React component that renders after fetch has finished?
- how to output current rendered component in react testing library unit test
- How to check the value of a nested React component in a unit test with Enzyme and Jest
- How to unit test React functions passed in as prop to child component with Enzyme shallow wrapper
- How to Unit test the rendering of a child component in the parent component using react testing library?
- How to test this component with react testing library - just a starter with this new testing library
- How to unit test the output of a React component method in a React Router / Redux app with Enzyme
- How to unit test a React functional component using hooks useEffect,useDispatch and useSelector and Redux?
- How To Unit Test React Component With react-intl, react-router-dom v4 and TypeScript
- How do i unit test using mocha/chai/sinon if a variable has a react component as value?
- How to unit test react hooks component that fetches data in useEffect using Enzyme?
- How do I mimic props available = TRUE in my unit test so I can test my react component in isolation
- How to unit test a callback function was called on a React component using Cypress
- How to get all the child elements inside a component in unit test using react and enzyme?
- How can I unit test my react component prop API
- How to unit test a component under React Router 4
- How do I unit test stateChange callback from the component in react hooks?
- How to test a react component that is dependent on useContext hook?
- How to unit test a method of react component?
- How to test style for a React component attribute with Enzyme
- How to test a prop update on React component
- Figuring out how to mock the window size changing for a react component test
- React & Jest, how to test changing state and checking for another component
- How to test a React component with RouteComponentProps?
- How unique should a React component Key be?
- How to mock out sub-components when unit testing a React component with Jest
More Query from same tag
- Is window.__INITIAL_STATE__ still the preferred way to pass initial state to the client in React Universal apps?
- Jest: TypeError: $(...).modal is not a function
- React Pass history to a component defined in the Router
- react redux split reducer change prev state
- Pushing indents before and after main body in typescript?
- React, state not getting updated when calling the related setState
- How to fire onSelectStart in React/JSX?
- React forwarding application component
- How to test function with another function inside with Jest?
- React router depending on the state of the React component
- Finding values or objects in a json file with nested objects and passing the result object to child in Javascript and react
- How to use state as checked atribute in ReactJs?
- React-router 2.0: passing username from login to children
- How can I send my Instagram access token from my Express server to React client?
- How to check for every item on the index 0 of an array if are falsy except for 2?
- How can I pass multiple parameters through a React <select> component?
- How to stop restarting for loop when dependency change in useEffect (React js)
- React reading from firebase, getting error
- React/Node app not working on Chrome "Error running template: Invariant Violation: Invalid hook call"
- How to have consistent width in material ui
- Calling a function recursively in reactjs
- Uncaught TypeError: can't access property "button", theme.typography is undefined
- React - Axios call make too many requests
- React state does not re-render
- How to change update an object within a useState array
- How to show an input after selecting a select in React js
- Using destructuring assignment results to not defined
- React Cannot read property state of undefined with API call
- Render is called twice when fetching data from a REST API
- Why state is not declared when it was set properly?