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(jest-config): Allow exactly one project #7498

Merged
merged 4 commits into from
May 2, 2019

Conversation

theneva
Copy link
Contributor

@theneva theneva commented Dec 11, 2018

Summary

This fixes the issue described in #7496, where Jest ignores the project's configuration if the config's projects array resolves to exactly one project.

Fixes #7496

Test plan

I've tested that it works in my reproduction case, but I'm not sure how to write a test case for it, or why the test checked > 1 in the first place.

I'll be happy to write a test if someone nudges me in the right direction!

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@thymikee
Copy link
Collaborator

@SimenB I'm confused, wasn't this fixed in #5176?

@theneva
Copy link
Contributor Author

theneva commented Dec 11, 2018

Hmm, I'm not going to fix the broken test(s) until I know if this is necessary 😄

@SimenB
Copy link
Member

SimenB commented Dec 11, 2018

#5176 is for object config, not a string pointing to a directory containing config.

An integration test in e2e/__tests__/multi_project_runner.test.js is failing though, @theneva mind taking a look? You can probably add a test of your own there. Take a look at https://github.com/facebook/jest/blob/master/CONTRIBUTING.md#integration-tests for some information about how the e2e tests work

@thymikee
Copy link
Collaborator

Yea, but this issue was marked closed as a result: #4117

@SimenB
Copy link
Member

SimenB commented Dec 11, 2018

Oh! Haha. That has to have been an error. Seeing as this issue has a better reproduction, we should keep this open I think

@thymikee
Copy link
Collaborator

And nobody noticed... XD

@SimenB
Copy link
Member

SimenB commented Dec 11, 2018

I went through and commented in that issue I closed, and closed 2 duplicates, pointing to #7496.

I'll hide shamefully in a corner 😅

@theneva
Copy link
Contributor Author

theneva commented Dec 11, 2018

I've added an e2e test which demonstrates the issue (breaks before the change from 1 to 0, passes after the change) in eebc494

However, the change seems to affect other stuff. Based on the other integration test that now breaks, my guess is that the root project counts towards the projects.length if no projects array is specified.

Perhaps the root project should always be counted, even when projects is set to a single non-root project? That would make us able to consistently check against > 1.

Thoughts, anyone? 😄

@SimenB
Copy link
Member

SimenB commented Jan 10, 2019

my guess is that the root project counts towards the projects.length if no projects array is specified.

Yup, https://github.com/facebook/jest/blob/665a93eec70c4f2d7809d1848fbc8ca60cfd8361/packages/jest-cli/src/cli/index.js#L213-L234

Perhaps the root project should always be counted, even when projects is set to a single non-root project? That would make us able to consistently check against > 1.

There is some config that only applies to the root project (GlobalConfig) and not to others (ProjectConfig). I'm not sure if it's safe to ignore the difference. Maybe? Try it out and see what breaks? As long as zero projects, 1 project and multiple projects still work, we should be good

@github-actions
Copy link

This pull request 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 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jest config projects array can't handle only one item
5 participants