Skip to content

fix: remove unsupported --related flag from vitest invocation#37975

Merged
pelikhan merged 1 commit into
mainfrom
copilot/fix-impacted-test-suite
Jun 9, 2026
Merged

fix: remove unsupported --related flag from vitest invocation#37975
pelikhan merged 1 commit into
mainfrom
copilot/fix-impacted-test-suite

Conversation

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

vitest 4.x dropped the --related CLI flag, causing make test-impacted-js to fail with CACError: Unknown option '--related'.

Changes

  • Makefile: Remove --related from the test-impacted-js target. Changed files are already passed as positional arguments to vitest run, so vitest filters to those files directly without needing --related.
- xargs -0 -r npm run test:js -- --no-file-parallelism --related $(JS_IMPACTED_TEST_EXCLUDES)
+ xargs -0 -r npm run test:js -- --no-file-parallelism $(JS_IMPACTED_TEST_EXCLUDES)

…cted-js

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review June 9, 2026 00:01
Copilot AI review requested due to automatic review settings June 9, 2026 00:01
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel completed test quality analysis.

No test files were added or modified in this PR. The only change is in Makefile (1 line: removing the unsupported --related flag from vitest invocation). Test Quality Sentinel skipped — no tests to analyze.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #37975 does not have the 'implementation' label (has_implementation_label=false) and has 0 new lines of code in business logic directories (default_business_additions=0, threshold=100). Neither Condition A nor Condition B is met.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the repo’s JavaScript “impacted tests” Make target to be compatible with Vitest 4.x by removing a CLI flag that Vitest no longer supports.

Changes:

  • Remove the unsupported --related flag from the test-impacted-js Vitest invocation in the Makefile.
Show a summary per file
File Description
Makefile Drops --related from make test-impacted-js to avoid Vitest 4.x CLI errors.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment thread Makefile
Comment on lines 241 to +243
fi; \
echo "Running impacted JavaScript unit tests for changed files: $$CHANGED_JS_FILES"; \
cd actions/setup/js && printf '%s\n' "$$CHANGED_JS_FILES" | sed 's|^actions/setup/js/||' | tr '\n' '\0' | xargs -0 -r npm run test:js -- --no-file-parallelism --related $(JS_IMPACTED_TEST_EXCLUDES)
cd actions/setup/js && printf '%s\n' "$$CHANGED_JS_FILES" | sed 's|^actions/setup/js/||' | tr '\n' '\0' | xargs -0 -r npm run test:js -- --no-file-parallelism $(JS_IMPACTED_TEST_EXCLUDES)
@github-actions github-actions Bot mentioned this pull request Jun 9, 2026
@pelikhan pelikhan merged commit 8b3b6a1 into main Jun 9, 2026
71 of 89 checks passed
@pelikhan pelikhan deleted the copilot/fix-impacted-test-suite branch June 9, 2026 00:09

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /diagnose — approving with one observation on the semantic shift.

📋 Key Themes & Highlights

Summary

This is a minimal, correct fix for a real breakage. vitest 4.x removed --related, so the old target would fail immediately with CACError: Unknown option. Removing the flag restores the target to a working state.

One Thing to Verify

CHANGED_JS_FILES (line 237) collects all changed .ts/.js files — including non-test source files. The old --related would discover their companion test files; the new positional-arg approach passes them directly as test specs, which silently produces zero tests instead. If your project conventions ensure only *.test.ts files reach this command in practice, you are fine. If not, vitest related (the 4.x subcommand replacement) is worth a follow-up.

Positive Highlights

  • Fix is the minimum necessary change — no scope creep
  • PR description clearly explains both the cause and the rationale
  • Root cause correctly identified: unsupported flag, not a logic error

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 152.7 AIC · ⌖ 13.2 AIC

Comment thread Makefile
fi; \
echo "Running impacted JavaScript unit tests for changed files: $$CHANGED_JS_FILES"; \
cd actions/setup/js && printf '%s\n' "$$CHANGED_JS_FILES" | sed 's|^actions/setup/js/||' | tr '\n' '\0' | xargs -0 -r npm run test:js -- --no-file-parallelism --related $(JS_IMPACTED_TEST_EXCLUDES)
cd actions/setup/js && printf '%s\n' "$$CHANGED_JS_FILES" | sed 's|^actions/setup/js/||' | tr '\n' '\0' | xargs -0 -r npm run test:js -- --no-file-parallelism $(JS_IMPACTED_TEST_EXCLUDES)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/diagnose] The removal of --related is correct for vitest 4.x compatibility, but worth noting the semantic shift: --related would discover test files that import the changed files (indirect coverage), while positional args now tell vitest to run those files directly as test specs.

For .test.ts files this is identical. For plain source files (e.g. utils.ts) that appear in CHANGED_JS_FILES, the old path found their companion test; the new path hands utils.ts to vitest as a test spec, which will produce zero test results rather than an error.

💡 Suggested Makefile comment + optional follow-up

Add a brief comment so future maintainers understand why --related is absent:

# Note: vitest 4.x removed --related; files are matched as test-spec patterns directly.
cd actions/setup/js && printf '%s\n' "$$CHANGED_JS_FILES" | sed 's|^actions/setup/js/||' | tr '\n' '\0' | xargs -0 -r npm run test:js -- --no-file-parallelism $(JS_IMPACTED_TEST_EXCLUDES)

If CHANGED_JS_FILES can include non-test source files, consider using vitest related subcommand (introduced in vitest 4.x as the CLI replacement for --related):

cd actions/setup/js && printf '%s\n' "$$CHANGED_JS_FILES" | sed 's|^actions/setup/js/||' | xargs npm run test:js -- related --no-file-parallelism $(JS_IMPACTED_TEST_EXCLUDES)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete fix — test-impacted-js silently skips tests for source-file changes.

Details

Removing the unsupported --related flag is correct, but the replacement mechanism is missing. With vitest run [source-files], vitest treats the file names as path-filter substrings against test-file paths. Because foo.cjs is not a substring of foo.test.cjs, zero test suites match — and vitest exits 0 silently. Any PR touching only source files passes CI with no JS tests run.

The correct replacement is the vitest related [files] subcommand (import-graph–aware). See inline comment for the two-line fix.

🔎 Code quality review by PR Code Quality Reviewer · ⌖ 12.9 AIC

Comment thread Makefile
fi; \
echo "Running impacted JavaScript unit tests for changed files: $$CHANGED_JS_FILES"; \
cd actions/setup/js && printf '%s\n' "$$CHANGED_JS_FILES" | sed 's|^actions/setup/js/||' | tr '\n' '\0' | xargs -0 -r npm run test:js -- --no-file-parallelism --related $(JS_IMPACTED_TEST_EXCLUDES)
cd actions/setup/js && printf '%s\n' "$$CHANGED_JS_FILES" | sed 's|^actions/setup/js/||' | tr '\n' '\0' | xargs -0 -r npm run test:js -- --no-file-parallelism $(JS_IMPACTED_TEST_EXCLUDES)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silent test skip for source-file changes: removing --related without a replacement means test-impacted-js no longer runs tests for changed source files — only changed test files get exercised, giving false CI confidence.

💡 Root cause and suggested fix

What broke

vitest run treats positional arguments as path-filter substrings matched against test-file paths. A changed source file foo.cjs is passed as the filter pattern — but foo.cjs is not a substring of the corresponding test file foo.test.cjs. Vitest finds zero matching test suites and exits 0 silently.

This means: any PR that touches only source files (e.g. add_comment.cjs) will run no JavaScript tests at all, yet make test-impacted-js reports success.

Why --related was wrong to begin with

--related is not a flag for vitest run; it is a subcommand (vitest related [files]). Passing it to vitest run was already invalid. The commit correctly removes the unsupported flag, but the fix is incomplete.

Correct fix

Switch from vitest run to vitest related. The simplest approach — add a dedicated npm script and call it here:

// package.json
"test:js-related": "vitest related"
# Makefile (line 243)
cd actions/setup/js && printf '%s\n' "$$CHANGED_JS_FILES" \
  | sed 's|^actions/setup/js/||' \
  | tr '\n' '\0' \
  | xargs -0 -r npm run test:js-related -- --no-file-parallelism $(JS_IMPACTED_TEST_EXCLUDES)

vitest related [files] builds an import graph and finds all test files that (transitively) import the listed source files — the original intended semantics.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants