Skip to content

[heft-jest-plugin] Fix --test-path-pattern being ignored on Jest 30#5828

Merged
iclanton merged 1 commit into
microsoft:mainfrom
iclanton:fix-heft-jest-test-path-pattern
Jun 9, 2026
Merged

[heft-jest-plugin] Fix --test-path-pattern being ignored on Jest 30#5828
iclanton merged 1 commit into
microsoft:mainfrom
iclanton:fix-heft-jest-test-path-pattern

Conversation

@iclanton

@iclanton iclanton commented Jun 9, 2026

Copy link
Copy Markdown
Member

Summary

heft test --test-path-pattern <regex> was silently running every test in a project. The Heft Jest plugin was passing the regex to Jest under the field name testPathPattern (singular) on Config.Argv.

Root cause

In Jest 30, the Config.Argv property was renamed from testPathPattern (singular) to testPathPatterns (plural). jest-config now treats the old name as deprecated and ignores it, which causes Jest to run with no path filter at all.

See jest-config v30:

testPathPattern: () => formatDeprecation(
  'Option *testPathPattern* was replaced by *--testPathPatterns*. '
  + '*--testPathPatterns* is only available as a command-line option.'
)

Fix

Write the argv as testPathPatterns (plural). The user-facing CLI parameter and the IJestPluginOptions.testPathPattern option are unchanged.

Repro

In libraries/rush-lib:

heft test --test-path-pattern ChangeFile.test

Before the fix this ran the entire suite. After the fix it correctly runs only ChangeFile.test.js.

Jest 30 renamed the Config.Argv field from testPathPattern to testPathPatterns (plural). The Heft Jest plugin was still writing the old key, so jest-config silently ignored it and every test ran.
@iclanton iclanton merged commit 51f85c6 into microsoft:main Jun 9, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from Needs triage to Closed in Bug Triage Jun 9, 2026
@iclanton iclanton deleted the fix-heft-jest-test-path-pattern branch June 9, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

2 participants