-
-
Notifications
You must be signed in to change notification settings - Fork 145
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
Snapshot of style rule(s) #117
Comments
I guess I just want some way to snapshot styles, without caring about the rest of the DOM. I don't want to mount and snapshot the whole component because the snapshots might be huge. And So maybe something like |
Thank you very much, @WickyNilliams. |
I would love this feature too 👍 |
Will it be released? It will be so cool!! |
I see it's been a while since any activity on this issue so I'll take a look at it and see if I can submit a PR soon. |
@MicheleBertoli I have an idea for a basic initial implementation and would appreciate your thoughts before I submit a PR. Currently we have An example usage: import { getStyleRule } from 'jest-styled-components';
describe('MyComponent', () => {
it('should ...', () => {
expect(getStyleRule(<MyComponent />, 'color')).toMatchSnapshot();
})
}) In a follow-up PR, we could look at creating an entirely new assertion, |
+1 I have a couple of questions:
For example: const tree = renderer.create(<Button />).toJSON() // or shallow(<Button />), or mount(<Button />)
expect(getStyleRule(tree, 'color')).toMatchSnapshot();
Thank you very much for working on this, @joebourne. |
As I'll be abstracting existing logic, users will indeed be able to choose how to render components, and the modifiers will also be available as No problem, I'll submit a PR this week. |
Is this still in the works? Would love to use it our projects! |
It would be nice if we could snapshot style rules, instead of explicitly asserting on them in tests.
e.g. instead of:
we could do something like (API up for discussion):
The text was updated successfully, but these errors were encountered: