score:1
You can use .find(Jumbotron)
and use that for matching as snapshot, for example:
const wrapped = component.find(Jumbotron);
expect(toJson(wrapped)).toMatchSnapshot();
I had a more complex example involving withRouter()
and I was restoring to removing all keys from the output before matching as snapshot. Well, until testing for React-Router v4 gets more solid with Jest and snapshot testing. Example:
export function removeKeys(object) {
if (object === undefined || object === null) {
return object;
}
Object.keys(object).forEach((key) => {
if (typeof object[key] === 'object') {
removeKeys(object[key]);
} else if (key === 'key') {
delete object[key];
}
});
return object;
}
...
expect(removeKeys(toJson(component))).toMatchSnapshot();
Source: stackoverflow.com
Related Query
- Testing debounced function in React component with Jest and Enzyme
- Testing React Router with Jest and Enzyme
- React testing state of component with Jest and Enzyme
- Testing component function in React with Enzyme and Jest
- How to mock React component methods with jest and enzyme
- How to read console.log from a mounted component with Enzyme and Jest in Create React App
- _this.store.getState is not a function when testing react component with enzyme and mocha
- Testing component with react-router v4, Jest and Enzyme
- Testing react router v4 with jest enzyme
- React testing with Jest and Enzyme (in Symfony) got "Syntax Error: Unexpected token import"
- Getting started testing React components with Enzyme and Jest
- Testing Material UI Component with Jest and Enzyme
- Testing React component with Enzyme Jest finding HTML element
- How to check the value of a nested React component in a unit test with Enzyme and Jest
- How to test styles and media queries rendered by a React component with Jest and/or Enzyme
- testing custom react methods with jest and enzyme
- Test an whole table React component cells with jest and Enzyme
- Testing a React Hooks component with Jest / Enzyme & Axios
- How to mock React component events with jest and enzyme
- Testing react app with jest and enzyme token problem
- React testing with Jest and Enzyme @react-google-maps/api returns TypeError: Cannot read property 'maps' of undefined
- Testing react component with enzyme and expect fails
- Testing a React component with Jest / Enzyme & Axios
- Mock a custom service with jest and enzyme for a react component
- Testing component created using styled component with jest and enzyme
- Testing With Jest and Enzyme. Spy On a method of a react component
- Testing React Component with Enzyme and Mocha
- Testing React Component with Jest and Enzyme. Error: Can't read property of map is undefined
- Testing simple React component using Jest and enzyme - what did I wrong?
- how to test component while passing boolean value with react testing library and jest
More Query from same tag
- Material-ui Card component's shadows and bottom get clipped when within GridList
- SPA when route change reset store value to default
- React JS - trigger event on certain state value
- Why my array getting appended instead of clearing and Adding new data
- Set state based on previous one in render function
- Enable component specific hot reloading?
- Enhance layout integration of react-select into material-ui
- Custom widget with input loses focus in react-jsonschema-form when formData is passed as a prop to the form
- React context in MPA (one context for different apps)
- In which case react key prop warning can be ignored
- How to define variables in JSX
- How can I set a variable on a function component with Typescript
- Testing/mocking a service inside functional container in React/Jest
- Can't send a multipart/form-data from a react view with axios
- How to add types to the own props of the component next to those of the theme?
- Link from react-router-dom is not working properly with material-ui
- React.js search filter in treeview
- Bootstrap buttons won't display inline-block
- How do you access the values from a redux form in a reducer?
- Error in building app with react-hook-form using TS
- How to alias a Material-UI import?
- after fetch, my website data always reloading. so search function does not work
- Is there a way to make nextjs Image have fixed height and responsive width?
- React - what is the proper way to reload after multiple axios requests are done
- ReactJS how to loop through dynamically named refs
- How do I merge two Javascript Objects into one?
- React Component properties "state" and "setState" are not recognized in TypeScript
- React: Let child class assign state?
- I can not return data with useSelector in react redux
- What should be the type of props when styling another Styled Component?