-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jest utilities for Styled Components #76
Milestone
Comments
arcticicestudio
added a commit
that referenced
this issue
Dec 13, 2018
References: (1) https://github.com/styled-components/jest-styled-components Associated epics: GH-38 Associated issues: GH-39 GH-76
arcticicestudio
added a commit
that referenced
this issue
Dec 13, 2018
This commit integrates jest-styled-components (1), a set of utilities for testing "Styled Components" (2) with Jest () that improves the napshot testing experience and provides a brand new matcher to make expectations on the style rules. This is the officially recommended library styled-components for Jest integration (3). Instead of storing the generated class names in snapshots it allows to track the actual CSS rules and attributes for better comparison what changed and if the change is even really related to the affected component. > Configuration To enable this features the package is simply imported in the test framework setup file defined in Jest's `setupTestFrameworkScriptFile` field (GH-39). > Custom Style Matcher The custom `toHaveStyleRule` matcher (4) is useful to test if a given rule is applied to a component. It will be added to the extended global `except` object when the main package file is being imported. References: (1) https://github.com/styled-components/jest-styled-components (2) https://www.styled-components.com (3) https://jestjs.io (4) https://github.com/styled-components/jest-styled-components#tohavestylerule Associated epics: GH-38 Associated issues: GH-39 GH-76
arcticicestudio
added a commit
that referenced
this issue
Dec 15, 2018
Instead of returning a simple object with the default `ReactComponent` key the mock now returns an real `<svg>` React component. GH-76
arcticicestudio
added a commit
that referenced
this issue
Dec 15, 2018
This improves the configuratibility and simplifies the testing. GH-76
arcticicestudio
added a commit
that referenced
this issue
Dec 15, 2018
arcticicestudio
added a commit
that referenced
this issue
Dec 15, 2018
…ies-for-styled-components Jest utilities for Styled Components
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This issue documents the integration of the jest-styled-components, a set of utilities for testing Styled Components with Jest that improves the snapshot testing experience and provides a brand new matcher to make expectations on the style rules.
This is the officially recommended library styled-components for Jest integration.
Instead of storing the generated class names in snapshots it allows to track the actual CSS rules and attributes for better comparison what changed and if the change is even really related to the affected component.
Before
After
Configuration
To enable this feature the package can simply being imported in the setup file defined in Jest's
setupTestFrameworkScriptFile
field implemented in #39.Custom Style Matcher
The custom
toHaveStyleRule
matcher is useful to test if a given rule is applied to a component. It will be added to the extended globalexcept
object when the main package file is being imported.Tasks
test/setup.js
).The text was updated successfully, but these errors were encountered: