@emotion/jest - react test library with emotion
See original GitHub issueIt’s my first time to use emotion and I am a bit confused about what would be the best way to test with emotion and @testing-library/react.
When I check the snapshot, it doesn’t contain any style information and feels like this is not the correct way to do it.
exports[`Brands has default styles 1`] = `
<div>
<div
class="css-1anixd5-Brands eciq85e2"
/>
</div>
`;
it('has default styles', () => {
const { container } = renderWithTheme(<Container />)
expect(container).toMatchSnapshot()
})
})
what am I missing here? Any helps would be appreciated! thanks
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
emotion/jest
The easiest way to test React components with emotion is with the snapshot ... but @emotion/jest also works with enzyme and react-testing-library).
Read more >How to use jest-emotion and react-testing-library ... - Code Daily
We'll use jest-emotion to add in new matchers to Jest and combined with react-testing-library we'll be able to test our components are rendering...
Read more >React testing library not rendering Emotion CSS
I have tried using the "@emotion/jest/serializer" but still no luck. Component: <button role="button" css={(theme)=> { backgroundColor: ...
Read more >Testing Emotion Styles | Building SPAs - Carl Rippon
reacttests. Emotion is a popular CSS-in-JS library for React. One of the things I love about it is the ability to declare conditional...
Read more >@emotion/jest - npm
@emotion/jest. TypeScript icon, indicating that this package has built-in type declarations · Keywords.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is there any way to test an Element which defines Styling for all its direct children? I tried this in an
jest@25.5.4
@testing-library/react@11.2.5
and@emotion/jest@11.1.0
So I wrote an unit test:
But somehow the
@emotion/jest@11.1.0
wasn’t able to resolve styles provided by the Parent. So is there a solution to achieve this?Sure I will add an Codesandbox tomorrow, Issue is that there is not yet full support for nextjs 😬 if this not work I provide an Github Repo then.