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

Single file testing doesn't work correctly after migration to Jest 22 #5527

Closed
aakula-edmunds opened this issue Feb 12, 2018 · 7 comments · Fixed by #5582
Closed

Single file testing doesn't work correctly after migration to Jest 22 #5527

aakula-edmunds opened this issue Feb 12, 2018 · 7 comments · Fixed by #5582

Comments

@aakula-edmunds
Copy link

Do you want to request a feature or report a bug?
a bug

What is the current behavior?
Jest tries running test 2 times instead of 1

  • 1st run is successful
  • 2nd run fails with unmatched snapshot error if such test scenario exists

If the current behavior is a bug, please provide the steps to reproduce and
either a repl.it demo through https://repl.it/languages/jest or a minimal
repository on GitHub that we can yarn install and yarn test.

https://github.com/aakula-edmunds/sampleJestIssue

What is the expected behavior?
A test should be run only once.

Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.

https://github.com/aakula-edmunds/sampleJestIssue/tree/master/archetype/config/jest

@rickhanlonii
Copy link
Member

rickhanlonii commented Feb 13, 2018

Hey @aakula-edmunds, it looks like the issue on your branch happens on Jest 21 as well and is related to how you have the enzyme serializer configured (not a bug)

If you have any more questions, I'm happy to help more on stackoverflow or our discord channel

@dan-codes-16
Copy link

dan-codes-16 commented Feb 13, 2018

@rickhanlonii thanks a lot for your answer, but how is a double test related to enzyme configuration? If enzyme is removed at all jest still tries to execute the same test twice. Maybe it wasn't clear in the original message from @aakula-edmunds, but when you try to call $ yarn test /path/to/test-file.test.js jest tries to test this file twice like it is 2 separate test files. For me it looks like 1st test is done with /client project configuration and second with /server project configuration. And this behavior wasn't so in Jest 21.

@rickhanlonii
Copy link
Member

rickhanlonii commented Feb 13, 2018

Ah, I see! I can confirm this (introduced in 22.0.0)

When you run yarn test server/sample.test.jsx it runs both the client and server project configs for that single test file, even though the client config shouldn't run based on the testMatch

Thanks for following up @adaniliuk!

@rickhanlonii rickhanlonii reopened this Feb 13, 2018
@rickhanlonii
Copy link
Member

rickhanlonii commented Feb 13, 2018

Looks like this was introduced here

With that change, we will run the tests on the files passed in and ignore the matchers

@rickhanlonii
Copy link
Member

@aakula-edmunds @adaniliuk thanks for the report, this will be fixed in the next release

@dan-codes-16
Copy link

@rickhanlonii great, thanks a lot for a quick turn around!

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants