Skip to content

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

Closed

Description

@AndrewSouthpaw

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

Activity

  1. github-actions commented on Nov 1, 2023

    @github-actions
  2. AndrewSouthpaw commented on Nov 11, 2023

    @AndrewSouthpaw
    Author
  3. github-actions commented on Dec 11, 2023

    @github-actions
  4. AndrewSouthpaw commented on Dec 11, 2023

    @AndrewSouthpaw
    Author
  5. github-actions commented on Jan 10, 2024

    @github-actions
  6. AndrewSouthpaw commented on Jan 10, 2024

    @AndrewSouthpaw
    Author
  7. 3 remaining items

  8. github-actions commented on Mar 11, 2024

    @github-actions
  9. AndrewSouthpaw commented on Mar 12, 2024

    @AndrewSouthpaw
    Author
  10. SimenB commented on Mar 12, 2024

    @SimenB
    Member

    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?

  11. AndrewSouthpaw commented on Apr 29, 2024

    @AndrewSouthpaw
    ContributorAuthor

    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.

  12. jonscheiding commented on Oct 28, 2025

    @jonscheiding

    I came across this while troubleshooting similar behavior, specifically behavior 4 in the description:

    1. yarn jest --projects=src/project1 --showConfig shows global config not set (no testTimeout specified)

    I'm not clear whether @AndrewSouthpaw or @SimenB are saying this is part of the bug, but for me it's quite surprising behavior. Other flags that have analogues in the config file (e.g. --globalSetup, --testTimeout) don't behave this way.

  13. SimenB commented on Aug 28, 2026

    @SimenB
    Member
  14. github-actions commented on Sep 28, 2026

    @github-actions

    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.

  15. locked as resolved and limited conversation to collaborators on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions