Skip to content

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

Open
iclanton wants to merge 1 commit into
microsoft:mainfrom
iclanton:fix-heft-jest-test-path-pattern
Open

[heft-jest-plugin] Fix --test-path-pattern being ignored on Jest 30#5828
iclanton wants to merge 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

1 participant