Skip to content

Jest: <rootDir> in testPathIgnorePatterns is matched literally #251

Closed

Description

@FredApps

Jest replaces a leading <rootDir> in testPathIgnorePatterns with the root directory. extractTestPatterns in src/repo/runner-universe.ts keeps the token, and compileIgnoreRegexes compiles it literally, so the pattern never matches. <rootDir>/… is the form the Jest docs recommend.

Repro: jest.config.js with testMatch: ['**/*.test.js'] and testPathIgnorePatterns: ['<rootDir>/e2e/']; files src/a.test.js, e2e/helper.js, e2e/flow.test.js. Change e2e/helper.js.

Expected: e2e/flow.test.js is not in the test universe, as with testPathIgnorePatterns: ['/e2e/'].

Actual: testFilePaths contains e2e/flow.test.js, it is selected, and the planned command is npx --no-install jest --config jest.config.js e2e/flow.test.js. Jest 29 exits 1 with No tests found, exiting with code 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions