question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CSS on snapshots are getting reordered on CI and different machines

See original GitHub issue

Current behavior:

When the tests run locally the snapshots are ok but when it runs on the CI it gets differences on the snapshots. I tried locally in 3 machines, 2 equal laptops (in one of them I run in Windows and Linux) same snapshots and in a different machine, it gave different snapshots like the same behaviour of CI. The problem seems to be very similar to some problems that were already fixed in previous versions https://github.com/emotion-js/emotion/issues/1878 https://github.com/emotion-js/emotion/pull/1880 I am not sure where is the problem or how to debug it.

Here is a couple of examples of the differences in the snapshots: Example 1 image Example 2 image

To reproduce:

I am not sure how to reproduce it on a CodeSandbox because I am using a lot of configuration and the problem is when it runs on the CI and different machines. Some relevant configurations are: (I turned off the source maps and the auto label just to be sure) { presets: [ ['@babel/preset-env', { modules: isTest ? 'commonjs' : false }], [ '@babel/preset-react', { runtime: 'automatic', development: isDev, importSource: '@emotion/react' } ] ], plugins: [ isDev && 'react-hot-loader/babel', [ '@emotion', { sourceMap: false, autoLabel: 'never', labelFormat: '[filename]--[local]' } ], '@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-optional-chaining', '@babel/plugin-proposal-nullish-coalescing-operator', 'lodash' ].filter(Boolean), env: { test: { plugins: [ [ '@emotion', { sourceMap: false, autoLabel: 'never', labelFormat: '[filename]--[local]' } ] ] } } }

  1. Run the tests in different machines

Expected behavior:

The snapshots should be the same in different local machines as also on the CI.

Environment information:

  • react version: 17.0.2
  • @emotion/react version: 11.6.0
  • @emotion/babel-plugin version: 11.3.0
  • @emotion/css version: 11.5.0
  • @emotion/jest version: 11.6.0
  • @emotion/styled version: 11.6.0
  • @testing-library/jest-dom version: 4.2.4
  • @testing-library/react version: 9.4.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Andaristcommented, Dec 10, 2021

Closing as it turned out to be the same problem as described here. Node 10 has been used on CI and its [].sort is somewhat unreliable when it comes to the final order of the sorted elements

1reaction
Andaristcommented, Dec 6, 2021

I would patch-package console.logs for all of those calls here: https://github.com/emotion-js/emotion/blob/26ded6109fcd8ca9875cc2ce4564fee678a3f3c5/packages/jest/src/create-serializer.js#L199-L209

I would inspect their results, compare between runs and focus on the function that yields different results - then I would patch-package even more console.logs into its implementation. That should help you to trace when the execution starts to diverge.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[jest-emotion] snapshots reordering css based on test order ...
Expected behavior: The order of the tests should not mutate other test snapshots. Removing, skipping, or moving a test should not fail other...
Read more >
Same code generating different snapshots on different machines
Go to all other PCs. Pull in the changes to package lock json (reject all local and accept all remote changes). Remove node_modules....
Read more >
Snapshot Tests Classname With Emotion/Styled - ADocLib
[jestemotion] snapshots show every style changed when any html attribute Simply install I'm using yarn and run yarn test to see it. snapshot...
Read more >
Changes to Tokyo features and products
Cumulative release notes summary on changes to Tokyo features and products.
Read more >
16 Selenium Best Practices For Efficient Test Automation
The situation of executing automated cross browser tests on a local machine is entirely different from being executed on a continuous build ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found