Making Style Assertions for Styled Components Testing
In this lesson you’ll learn to test the styled-components by making assertions about styles using various Jest methods.
We'll cover the following...
Making assertions about styles
The following is how to make different assertions about styles:
-
To make assertions about the styles that styled-components generate, you’ll need the Jest styled-components plugin. Install
jest-styled-components
with npm:$ npm install --save-dev jest-styled-components@6.3.1 + jest-styled-components@6.3.1
-
Then you’ll need to bring in the plugin before running your tests:
Press + to interact
import Adapter from 'enzyme-adapter-react-16';import { configure } from 'enzyme';import 'jest-styled-components';configure({ adapter: new Adapter() });
Access this course and 1400+ top-rated courses and projects.