Default useLegacyCodeLens to false for Pester 5 CodeLens - #5513
Conversation
There was a problem hiding this comment.
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
useLegacyCodeLensdefault fromtruetofalsein the feature implementation. - Update the
powershell.pester.useLegacyCodeLenssetting default tofalse. - 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
falsemakes-MinimumVersion5the 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-MinimumVersion5on 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");
}
|
CI red on mac/windows isn't from this PR:
Ubuntu green. Happy to push an empty commit or rebase if a rerun is easier than fighting macOS. 🙂 |
|
Tried re-building, feels like infra issue rather than mine. |
|
Fix: #5514 |
|
Jakub Jareš (@nohwnd) thanks! I'll investigate, I saw some of the same flakiness lately as well on PRs I've made. |
|
Justin Grote (@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>
1f234f7 to
c482cde
Compare
Pester 4 has been EOL since 2020 and Pester 5 is the current stable. Default the CodeLens to the Pester 5 layout (
Run TestsonIt,DescribeandContext) instead of the Pester 4 one (Run TestsonDescribeonly).package.json: flippowershell.pester.useLegacyCodeLens.defaultfromtruetofalse, update description.src/features/PesterTests.ts: flip the matching fallback inpesterConfig.get<boolean>("useLegacyCodeLens", …)to keep runner and CodeLens in sync.Impact: users who have not explicitly set the value get CodeLens on
ItandContexttoo, and clicking it runsInvokePesterStub.ps1with-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: setpowershell.pester.useLegacyCodeLenstotruein user or workspace settings.Verified:
npm run compile,npm run lint,npm run formatclean. No tests in this repo reference the setting. PSES already handles both modes inPesterCodeLensProvider.cs.