score:4
Accepted answer
const wrapper = mount(<mycomponent foo={10} />);
expect(wrapper.props().children).to.equal(10);
edit:
and like @must keem pointed out, this works also:
const wrapper = mount(<mycomponent foo={10} />);
expect(wrapper.instance().props.foo).to.equal(10);
Source: stackoverflow.com
Related Query
- How to get props of component when unit testing using jestjs
- How to get parent props in child component when using styled component in react
- How to test if a component is rendered with the right props when using react-testing-library?
- How to mock out sub-components when unit testing a React component with Jest
- How can I spread props to a React component that uses exact props when using Flow?
- How to get JSDOM to work with typescript when unit testing with a Chai\Mocha setup?
- How to get React/recompose component updated when props are changed?
- How to pass props to styled component when using theme?
- How to know if props have changed when using React.memo() with a functional Component
- How to Unit test the rendering of a child component in the parent component using react testing library?
- How to test the value of the props of react component rendered using react testing library
- How to display toast using react-toastify inside class component when props check is true
- How to get Component by dynamic testid using React Testing Library
- How to get value of nested props function for unit testing
- "No style rules found on passed Component" when unit testing direct child of styled component using react-testing-library
- How to refer to conditional elements when unit testing React components using jest and enzyme
- How to get rid of styling when using Link Component in React
- How to get another component when I click h1 tag in react using hooks?
- How to mock a parent component which passes props to child component using react testing library
- How to get state variables from one component to another when i'm using history.push?
- How to get all the child elements inside a component in unit test using react and enzyme?
- How to receive props from a parent component when using getStaticProps?
- How to mock a complex react component with props using Jest/ react testing library
- In Firebase when using push() How do I get the unique ID and store in my database
- How can I fix jsx-a11y/anchor-is-valid when using the Link component in React?
- How do I get an attribute of an element nested in a React component using Jest and/or Enzyme?
- How to prevent child component from re-rendering when using React hooks and memo?
- React js - How to mock Context when testing component
- How to mock ResizeObserver to work in unit tests using react testing library
- Component doesn't re-render when props change using useState hook
More Query from same tag
- Correct way to type a 'setState' function using React hook useState()
- ReactJS: onClick inside .map
- react redux async action call next function after finishing the function
- Get button value on clicked button react hooks
- Why won't my text input allow me to change the value within it?
- How to extends props from React.HTMLProps<HTMLButtonElement>?
- How to remove focus on inputs after submisssion of form in React
- Reactjs array map mutation
- How to pass dropdown values into mongodb in react?
- how to load radio buttons dynamically and use check property in react js?
- How to specify typescript type of a component with properties
- How to remove elements in an array based on their odd or even index?
- React Highcharts v9.2 Solid Gauge Rounded Ends
- Returning a value from an Async Function. AWS/React
- useEffect not running on refresh
- Ajax request won't display in react render function
- Passing client-side parameters to the server-side with React/redux and Express (EMPTY_RESPONSE error)
- How would you rewrite these 3 functions so that it can called by one function?
- running node package manager to build but got error
- Access latest state value in the same function that is used to set the state
- How to use generic types correctly in HOC components?
- Why promise returned by axios.get is not resolved?
- Equivalent of FlatList from React Native in React
- react i18n - Functions are not valid as a React child
- Yup.when: "`NaN` (cast from the value `NaN`)"
- How to handle properties that exist in one overload and don't in another?
- How to use Django template in ReactJS
- If/else in FormatJS / React-intl
- React useState Not Storing New Values After UseEffect Intervals
- React router 4 appending extra query param