jest icon indicating copy to clipboard operation
jest copied to clipboard

[Bug]: Multiple `--projects` specified causes `--config` to not be used

Open AndrewSouthpaw opened this issue 2 years ago • 13 comments

Version

29.7.0

Steps to reproduce

  1. Clone my repro: https://github.com/AndrewSouthpaw/2023-10-jest-projects-bug-repro
  2. yarn
  3. yarn jest --showConfig with 2+ projects in the config shows the global config properly set (testTimeout: 30000), with projects listed
  4. yarn jest --projects=src/project1 --showConfig shows global config not set (no testTimeout specified)
  5. yarn jest --projects=src/project1 --showConfig -c jest.config.js shows global config properly set
  6. yarn jest --projects=src/project1 src/project2 --showConfig -c jest.config.js shows global config not set

This demonstrates the -c flag is ignored entirely when 2 or more projects are specified in --projects:

  1. yarn jest --projects=src/project1 src/project2 --showConfig -c doesNotExist.config.js does not error
  2. yarn jest --projects=src/project1 --showConfig -c doesNotExist.config.js does error, as expected

Project structure:

src
|__ project 1
   |__ jest.config.js
|__ project 2
   |__ jest.config.js
jest.config.js

Sample global jest.config.js:

const config = {
  "projects": ["src/project1", "src/project2"],
  "testTimeout": 30000,
}
  
module.exports = config

Expected behavior

When providing -c jest.config.js, it is used regardless of whether I provide 1 or 2+ projects under --projects

Actual behavior

-c flag is not used when --projects receives 2 or more arguments.

Additional context

No response

Environment

System:
    OS: macOS 13.6
    CPU: (10) arm64 Apple M1 Max
  Binaries:
    Node: 18.17.0 - ~/.nvm/versions/node/v18.17.0/bin/node
    Yarn: 3.2.4 - ~/.nvm/versions/node/v18.17.0/bin/yarn
    npm: 9.6.7 - ~/.nvm/versions/node/v18.17.0/bin/npm
    pnpm: 8.8.0 - ~/.nvm/versions/node/v18.17.0/bin/pnpm
  npmPackages:
    jest: ^29.7.0 => 29.7.0

AndrewSouthpaw avatar Oct 01 '23 18:10 AndrewSouthpaw

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Nov 01 '23 12:11 github-actions[bot]

Still an issue.

AndrewSouthpaw avatar Nov 11 '23 02:11 AndrewSouthpaw

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Dec 11 '23 03:12 github-actions[bot]

Still an issue

AndrewSouthpaw avatar Dec 11 '23 06:12 AndrewSouthpaw

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Jan 10 '24 08:01 github-actions[bot]

Still an issue

-- Andrew Smith 971.219.3670 Code http://www.andrewsouthpaw.com/ | Dance http://www.andrewsmithdance.com/

On Wed, Jan 10, 2024 at 12:05 AM github-actions[bot] < @.***> wrote:

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

— Reply to this email directly, view it on GitHub https://github.com/jestjs/jest/issues/14586#issuecomment-1884362500, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHSOTGK46FQNRCV2EXJAMLYNZDTFAVCNFSM6AAAAAA5OPQE2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBUGM3DENJQGA . You are receiving this because you authored the thread.Message ID: @.***>

AndrewSouthpaw avatar Jan 10 '24 14:01 AndrewSouthpaw

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Feb 09 '24 16:02 github-actions[bot]

Still an issue

-- Sent from a tiny screen; please excuse brevity or errors, or both.

On Fri, Feb 9, 2024 at 08:04 github-actions[bot] @.***> wrote:

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

— Reply to this email directly, view it on GitHub https://github.com/jestjs/jest/issues/14586#issuecomment-1936189995, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHSOTDR37GW6IOROGLA5U3YSZCJDAVCNFSM6AAAAAA5OPQE2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZWGE4DSOJZGU . You are receiving this because you authored the thread.Message ID: @.***>

AndrewSouthpaw avatar Feb 10 '24 05:02 AndrewSouthpaw

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Mar 11 '24 07:03 github-actions[bot]

Still an issue

AndrewSouthpaw avatar Mar 12 '24 04:03 AndrewSouthpaw

I'm always a bit confused by the differentiation of project and global config 😅 Specifically, testTimeout seems very much like a project config thing (e.g. integration tests should probably have a higher timeout than unit tests). Regardless, this is obviously a bug!

Would you be up for sending a PR?

SimenB avatar Mar 12 '24 07:03 SimenB

Definitely would be up for it! At this point Jest seems like a pretty large project, if you have any pointers on where files to get started / where you think the problem is located, that would be most welcome. Otherwise I'll try to find time to start digging around at some point and see where I wind up.

AndrewSouthpaw avatar Apr 29 '24 14:04 AndrewSouthpaw