-
-
Notifications
You must be signed in to change notification settings - Fork 24
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 #77
Merged
arcticicestudio
merged 5 commits into
develop
from
feature/gh-76-jest-utilities-for-styled-components
Dec 15, 2018
Merged
Jest utilities for Styled Components #77
arcticicestudio
merged 5 commits into
develop
from
feature/gh-76-jest-utilities-for-styled-components
Dec 15, 2018
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
arcticicestudio
commented
Dec 15, 2018
References: (1) https://github.com/styled-components/jest-styled-components Associated epics: GH-38 Associated issues: GH-39 GH-76
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
Instead of returning a simple object with the default `ReactComponent` key the mock now returns an real `<svg>` React component. GH-76
This improves the configuratibility and simplifies the testing. GH-76
Codecov Report
@@ Coverage Diff @@
## develop #77 +/- ##
===========================================
+ Coverage 70.2% 75.37% +5.17%
===========================================
Files 54 54
Lines 198 199 +1
Branches 34 34
===========================================
+ Hits 139 150 +11
+ Misses 59 49 -10
Continue to review full report at Codecov.
|
svengreb
approved these changes
Dec 15, 2018
arcticicestudio
deleted the
feature/gh-76-jest-utilities-for-styled-components
branch
December 15, 2018 10:43
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.