score:2
I was able to recreate this locally, but what I realized was the first 2 expect
s passed, whereas the last one did not. That was because the DESKTOP
media query block is setting the background-color
to "purple", whereas the expect
is looking for "blue".
background-color: purple;
@media (max-width: ${DESKTOP}px) {
background-color: purple;
}
expect(<Component />).toHaveStyleRule(
{ 'background-color': 'blue' },
{ media: `(max-width: ${DESKTOP}px)` }
)
Let me know if that's not the problem you are actually seeing.
Source: stackoverflow.com
Related Query
- How to test styles and media queries rendered by a React component with Jest and/or Enzyme
- How to test with jest and typescript with types a basic react function component
- How to test a React component that has Router, Redux and two HOCs... with Jest and Enzyme?
- How to check the value of a nested React component in a unit test with Enzyme and Jest
- How to test a React component that update over time with Jest and Enzyme?
- Jest with React - How do you render an entire component and test it?
- How can I test if child React component was rendered based on a URL change using Jest and Enzyme
- How to test React component with children using jest and enzyme?
- Test a component is rendered with React Router's render prop using Enzyme's shallow wrapper and Jest
- How to test if a prop is rendered correctly in a Component using Jest and Enzyme in React
- how to test component while passing boolean value with react testing library and jest
- How to test a className with the Jest and React testing library
- How to mock React component methods with jest and enzyme
- How to test a component with a nested container with React and Redux?
- How to test form submission in React with Jest and Enzyme? Cannot read property 'preventDefault' of undefined
- How to test snapshots with Jest and new React lazy 16.6 API
- How to test the state of a functional component in React with Jest (No Enzyme)
- How to read console.log from a mounted component with Enzyme and Jest in Create React App
- How to mock a React component lifecycle method with Jest and Enzyme?
- how can I test if useState hook has been called with jest and react testing library?
- How to test if a React component contains another component with Tape and Enzyme?
- How to test redux state update with react testing library and jest
- How to test a React component that uses context like in react-router 2.0 with Jest 0.8.x
- How to test functions in React with Jest and Enzyme
- Test an whole table React component cells with jest and Enzyme
- How to test if a component is rendered or not by jest and enzyme?
- How to test react functional component correctly using jest and enzyme?
- How to mock React component events with jest and enzyme
- How to make a react component that can be rendered with no data and later rendered with data?
- How to Test a function with Jest and React
More Query from same tag
- SyntaxError: Cannot use import statement outside a module React JS Antd
- Animating svg text using framer motion in React
- Is there a way to call a child's function from parent in React?
- Comparison based on valid string combination in javascript
- What's the point of Actions and Reducers in Redux?
- Sort an array based on another array
- discompose javascript react state with three dots, but why we are specifying state and state's attribute separately
- How to hide antd Modal header
- Keeping placeholder visible when typing
- What is "npm run build" in create-react-app?
- Warning about calling setState on an unmounted component
- Why do react elements outside of Route re-render?
- react and express app not allowing jsx
- How to generate components with each value from a JSON file in React?
- What does it mean to write two arrays together?
- how to add two onClick functions in React
- .map() Method on ReactJS
- getting error Dropdown `value` must be an array when `multiple` is set
- array.forEach is not a function
- Require class from another file in ReactJS
- Can't edit input value in React
- How to make the Service Worker cache data from API and update the cache when needed
- Destructuring props assignment
- Stop Re-Rendering of Parent Components. Only Re-Render Child Component
- Refer multiple Local video's path with API Response
- Material-UI: Text above background with opacity
- sharing data between disconnected components
- Next.js + Redux: Data fetched on server side never move to the page props
- How to make first sub-component of react-table open by default and open other sub-components manually
- KeyboardDatePicker MaterialUI - custom mask format