Skip to content
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

fix: don't generate styled-jsx randomized classes in jest snapshots #332

Merged
merged 2 commits into from
Mar 25, 2020

Conversation

amcgee
Copy link
Member

@amcgee amcgee commented Mar 25, 2020

In test environments we should:

  1. Use styled-jsx/babel-test instead of styled-jsx/babel
  2. Mock the styled-jsx/css function as a no-op

This results in clean snapshot output without randomly-generated jsx-##### which change whenever any css changes. See the styled-jsx README

},
development: {
plugins: [
[require('styled-jsx/babel'), { optimizeForSpeed: true }],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@varl should we turn optimizeForSpeed off here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this is for both apps and libraries, but I think it should be safe to build without optimizeForSpeed when the build output is in development...?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, will merge this and we can consider later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tricky thing is when production-mode components and development-mode components interact on the same page. Since styled-jsx is a singleton, that causes problems as production/development components inject CSS differently and are not compatible.

@amcgee amcgee merged commit eaafbab into master Mar 25, 2020
@amcgee amcgee deleted the fix/styled-jsx-test-noop branch March 25, 2020 15:08
dhis2-bot added a commit that referenced this pull request Mar 25, 2020
## [3.2.8](v3.2.7...v3.2.8) (2020-03-25)

### Bug Fixes

* don't generate styled-jsx randomized classes in jest snapshots ([#332](#332)) ([eaafbab](eaafbab))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 3.2.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

4 participants