Snapshot test crashes with the `coverage` option (& in CI env)
See original GitHub issueCurrent behavior:
After the migration from version 10 to version 11, the snapshot test crashes locally with the coverage
(react-scripts test --coverage
) option and in the CI
(circleci) environment with and without the coverage
option.
To reproduce:
Locally Snapshot tests:
react-scripts test
(OK)react-scripts test --coverage
(KO)
Example1:
Example2:
const StyledTable = styled(Table)`
border: none;
font-weight: normal;
.Table__row {
border: none;
}
...
`;
**Expected behavior:**
Environment information:
react
version: 17.0.2@emotion/react
version: 11.4.1@emotion/styled
version: 11.3.0@emotion/jest
version: 11.3.0react-scripts
version: 4.0.3
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Jest finds tests but doesn't collect coverage - Stack Overflow
The quick fix I said in my comment, using --watchAll instead, eg: react-scripts test --coverage --watchAll . Just for future reference, ...
Read more >jest-environment-node | Yarn - Package Manager
Jest will set process.env.NODE_ENV to 'test' if it's not set to something else. You can use that in your configuration to conditionally setup...
Read more >Continuous integration for React applications using Jest and ...
Begin by writing tests for the App component. A good starting point is adding a snapshot test to ensure that the component renders...
Read more >.NET Code Coverage for Continuous Integration using ...
How much of our code is being covered by our unit tests ? Are there areas we are not testing ? By capturing...
Read more >Configuring Vitest
To configure vitest itself, add test property in your Vite config. ... When importing such dependencies in Node environment using named ...
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
That is only an indication that this might be related to your project and that I can’t help you much since I don’t have access to it.
It’s hard to tell without seeing the code and the project as a whole.
The majority of related logic should be in
getStyleElements
,getClassNamesFromNodes
andgetPrettyStylesFromClassNames
. I recommend you to dive into th debugger and just compare both runs - with the--coverage
option and without it. This should answer all the questions.Then you should look into why
className
s are different here - I really don’t have magic tips here, I would myself just start debugging to get to the bottom of this.