Skip to content

Default useLegacyCodeLens to false for Pester 5 CodeLens#5513

Merged
andyleejordan merged 1 commit into
PowerShell:mainfrom
nohwnd:pester5-default
Jun 11, 2026
Merged

Default useLegacyCodeLens to false for Pester 5 CodeLens#5513
andyleejordan merged 1 commit into
PowerShell:mainfrom
nohwnd:pester5-default

Conversation

@nohwnd

@nohwnd nohwnd commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Pester 4 has been EOL since 2020 and Pester 5 is the current stable. Default the CodeLens to the Pester 5 layout (Run Tests on It, Describe and Context) instead of the Pester 4 one (Run Tests on Describe only).

  • package.json: flip powershell.pester.useLegacyCodeLens.default from true to false, update description.
  • src/features/PesterTests.ts: flip the matching fallback in pesterConfig.get<boolean>("useLegacyCodeLens", …) to keep runner and CodeLens in sync.

Impact: users who have not explicitly set the value get CodeLens on It and Context too, and clicking it runs InvokePesterStub.ps1 with -MinimumVersion5. On systems with only Pester 4 the stub falls back to v4 and warns; tests still run but the line-level filter is a v5 feature. Workaround: set powershell.pester.useLegacyCodeLens to true in user or workspace settings.

Verified: npm run compile, npm run lint, npm run format clean. No tests in this repo reference the setting. PSES already handles both modes in PesterCodeLensProvider.cs.

Copilot AI review requested due to automatic review settings June 11, 2026 09:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR changes the default Pester CodeLens behavior to prefer the Pester 5+ CodeLens experience by default, and updates the setting description accordingly.

Changes:

  • Flip useLegacyCodeLens default from true to false in the feature implementation.
  • Update the powershell.pester.useLegacyCodeLens setting default to false.
  • Rewrite the setting’s description to clarify legacy vs. Pester 5+ behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/features/PesterTests.ts Switches the runtime fallback/default for useLegacyCodeLens to false, affecting how test runs are configured.
package.json Updates the configuration schema default + description for powershell.pester.useLegacyCodeLens.
Comments suppressed due to low confidence (1)

src/features/PesterTests.ts:156

  • Changing the default to false makes -MinimumVersion5 the default behavior, which can cause test runs to fail for users who still have Pester 4 installed and haven’t explicitly configured this setting yet. Consider basing -MinimumVersion5 on detected/known Pester version (or only adding it after verifying Pester 5+ is available), and/or showing a targeted error/notification that explains the required Pester version when the run fails.
        const useLegacyCodeLens = pesterConfig.get<boolean>(
            "useLegacyCodeLens",
            false,
        );
        if (!useLegacyCodeLens) {
            launchConfig.args.push("-MinimumVersion5");
        }

Comment thread package.json
@nohwnd

nohwnd commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

CI red on mac/windows isn't from this PR:

  • mac: .vscode-test/user-data/1.12-main.sock path is 110 chars, over the macOS 103-char Unix socket limit. Same nesting passed yesterday with a shorter sock name (VS Code Insiders 1.12 just shipped).
  • windows: NuGet restore cancelled mid-run, looks like a flake.

Ubuntu green. Happy to push an empty commit or rebase if a rerun is easier than fighting macOS. 🙂

@nohwnd nohwnd closed this Jun 11, 2026
@nohwnd nohwnd reopened this Jun 11, 2026
@nohwnd

nohwnd commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Tried re-building, feels like infra issue rather than mine.

@nohwnd

nohwnd commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Fix: #5514

@JustinGrote

Copy link
Copy Markdown
Collaborator

@nohwnd thanks! I'll investigate, I saw some of the same flakiness lately as well on PRs I've made.

@nohwnd

nohwnd commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

@JustinGrote pls see #5514

Pester 4 has been EOL since 2020 and Pester 5 is the current stable. Default the CodeLens to the Pester 5 layout (`Run Tests` on `It`, `Describe` and `Context`) instead of the Pester 4 one (`Run Tests` on `Describe` only).

Users who haven't touched the setting will see CodeLens on `It` and `Context` blocks too, and clicking them runs `InvokePesterStub.ps1` with `-MinimumVersion5`. On systems where only Pester 4 is installed the stub falls back to v4 and warns; tests still run but the line-level filter is a v5 feature. Set `powershell.pester.useLegacyCodeLens` back to `true` to restore the old default.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@andyleejordan andyleejordan enabled auto-merge (squash) June 11, 2026 18:06
@andyleejordan andyleejordan merged commit 7884b75 into PowerShell:main Jun 11, 2026
4 checks passed
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.

4 participants