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

Projects
None yet
5 participants
@theneva
Copy link
Contributor

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

This comment has been minimized.

Copy link

commented Dec 11, 2018

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 cla@fb.com. Thanks!

@facebook-github-bot

This comment has been minimized.

Copy link

commented Dec 11, 2018

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

@thymikee

This comment has been minimized.

Copy link
Collaborator

commented Dec 11, 2018

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

@theneva

This comment has been minimized.

Copy link
Contributor Author

commented Dec 11, 2018

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

@SimenB

This comment has been minimized.

Copy link
Collaborator

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

This comment has been minimized.

Copy link
Collaborator

commented Dec 11, 2018

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

@SimenB

This comment has been minimized.

Copy link
Collaborator

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

This comment has been minimized.

Copy link
Collaborator

commented Dec 11, 2018

And nobody noticed... XD

@SimenB

This comment has been minimized.

Copy link
Collaborator

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

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link
Collaborator

commented Jan 10, 2019

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

Yup,

const getProjectListFromCLIArgs = (argv, project: ?Path) => {
const projects = argv.projects ? argv.projects : [];
if (project) {
projects.push(project);
}
if (!projects.length && process.platform === 'win32') {
try {
projects.push(realpath(process.cwd()));
} catch (err) {
// do nothing, just catch error
// process.binding('fs').realpath can throw, e.g. on mapped drives
}
}
if (!projects.length) {
projects.push(process.cwd());
}
return projects;
};

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

SimenB and others added some commits May 2, 2019

@SimenB

SimenB approved these changes May 2, 2019

@SimenB SimenB merged commit 4941d12 into facebook:master May 2, 2019

11 checks passed

ci/circleci: lint-and-typecheck Your tests passed on CircleCI!
Details
ci/circleci: test-browser Your tests passed on CircleCI!
Details
ci/circleci: test-jest-circus Your tests passed on CircleCI!
Details
ci/circleci: test-node-10 Your tests passed on CircleCI!
Details
ci/circleci: test-node-11 Your tests passed on CircleCI!
Details
ci/circleci: test-node-6 Your tests passed on CircleCI!
Details
ci/circleci: test-node-8 Your tests passed on CircleCI!
Details
ci/circleci: test-or-deploy-website Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
deploy/netlify Deploy preview ready!
Details
facebook.jest #20190502.9 succeeded
Details

@theneva theneva deleted the theneva:allow-exactly-one-project branch May 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.