Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Add a verification reference to the pester-migration skill - #6844

Open
nohwnd wants to merge 1 commit into
github:mainfrom
nohwnd:pester-field-notes
Open

nohwnd wants to merge 1 commit into
github:mainfrom
nohwnd:pester-field-notes

Conversation

@nohwnd

@nohwnd nohwnd commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

The pester-migration skill says what to change for each major jump. It does not say how to know
you changed it correctly, and on the v4 to v5 jump that is where things go wrong quietly.

The gap

A suite can lose most of its tests to the Discovery/Run split and still report success. Two
repositories, the same root cause, opposite symptoms:

one repository another
Pester 4 413 tests, green 1382 tests, 1365 passed
Pester 6, nothing changed 138 tests, still green 1360 tests, 14 passed
what a maintainer sees nothing wrong everything on fire

The first suite built its -TestCases data in BeforeAll, so during Discovery the data was empty
and three quarters of the tests were never created. Nothing failed and nothing warned.

The skill's workflow currently says "record pass/fail" for the baseline and "re-run until the result
matches the baseline" at the end. Both of those are satisfied by the green run above.

What this adds

references/verifying-a-migration.md, a new reference loaded for any jump:

  • the baseline is one row per test name and result, captured from a second pristine checkout, with a
    script that works on v4 and on v5+;

  • the comparison reports three numbers, tests only in the old run, tests only in the new run, and
    tests in both whose result changed, with the two cases that legitimately appear in the first column;

  • convert the CI gate along with the invocation. Measured on 5.3.3, 5.9.1 and 6.2.0:

    what happened Result FailedCount does if ($r.FailedCount -gt 0) fire?
    a test file that does not parse Failed 0 no
    an AfterAll that throws Failed 0 no
    a BeforeAll that throws Failed 1 yes
    passed + -Skip + Set-ItResult -Inconclusive Passed 0 no, correctly
  • the Discovery pass runs what you wrote, so a Describe level Mock has not applied while a
    Context body executes and the real command runs:

    Pester 4.10.1   real calls: 0   test Passed
    Pester 6.2.0    real calls: 1   test Failed, "Expected 'MOCKED', but got $null."
    
  • moving a mock's scope can stop it intercepting, with no error saying so;

  • a table of symptoms that are hard to connect to their cause: $null -contains $null being $true
    (one 41 line file produced 24,000 failures through it), foreach ($x in $null) running zero times
    where a pipeline runs once, InModuleScope needing the module during Discovery, a statement
    between two Describe blocks being teardown rather than setup, and markup in a test name;

  • two things that do work and are worth knowing, including that
    BeforeAll { Set-StrictMode -Version Latest } reaches the test bodies;

  • that asking which Pester is installed with Get-Command New-PesterConfiguration loads the newest
    one next to the version the script imported on purpose.

SKILL.md gains the reference row, a stronger baseline step, a "compare by name" step and two safety
rules. v4-to-v5.md gains a pointer from Fix 4 and three checklist lines.

Where the content comes from

All of it was measured while migrating eleven public PowerShell repositories from Pester 4 to Pester 6
during December 2026, including Crescendo, PScribo, OutSystems.SetupTools, PSSlack and d365fo.tools.
Where a number appears in the new file, it came from a run.

The FailedCount gate was wrong in seven of the eleven, including a repository maintained by the
Pester project itself and one whose migration two other people had done carefully from the release
notes. Nothing about FailedCount looks wrong, and no error message mentions it, which is why it
belongs in the skill rather than in a blog post.

Not changed

No frontmatter, so the generated README tables are unaffected and npm run build produces no diff.
The pester-should-migration skill needs nothing: its assertion-map.md already covers the strict
Should-BeTrue/Should-BeTruthy split, the Should -BeNullOrEmpty fan-out and Should-Be erroring
on a collection, which were the three things I had measured there.

🤖

The skill says what to change for each major jump. It does not say how to know you changed it
correctly, and that is where a Pester 4 to 5 migration goes wrong quietly: a suite can lose most of
its tests to the Discovery/Run split and stay green. One repository went from 413 tests to 138 and
reported success both times.

references/verifying-a-migration.md covers the parts that only show up in the field:

- the baseline is a list of test names, not a pass/fail count, and it lives in its own checkout
- compare the two runs test by test and report tests only in the old run, tests only in the new run,
  and changed results, because matching totals prove nothing
- convert the CI gate along with the invocation, because FailedCount stays at 0 when a test file
  does not parse and when an AfterAll throws
- the Discovery pass runs what you wrote, so a Describe level Mock has not applied while a Context
  body executes and the real command runs
- moving a mock's scope can stop it intercepting, with no error saying so
- symptoms that are hard to connect to their cause, including $null -contains $null being true,
  foreach over $null running zero times where a pipeline runs once, and InModuleScope needing the
  module during Discovery

SKILL.md gains the reference, two stronger workflow steps and two safety rules. v4-to-v5.md gains a
pointer from Fix 4 and three checklist lines.

Everything in the new file was measured while migrating eleven public repositories in December 2026.
No frontmatter changed, so the generated README tables are unaffected.

🤖
@nohwnd
nohwnd requested a review from a team as a code owner December 6, 2026 12:13
Copilot AI adaptive review requested due to automatic review settings December 6, 2026 12:13
@github-actions github-actions Bot added the skills PR touches skills label Dec 6, 2026
@github-actions

github-actions Bot commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

🔒 PR Risk Scan Results

Scanned 3 changed file(s).

Severity Count
🔴 High 0
🟠 Medium 0
ℹ️ Info 0

✅ No matching risk patterns were detected in changed files.

This is an automated soft-gate report. Findings indicate review targets and do not block merge by themselves.

@github-actions

github-actions Bot commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

🚦 Submission status: 🛠️ Requires submitter fixes

Risk tier: merge-risk:medium — New or substantially changed resource without privileged execution
Required to merge: passing submission-gate checks plus 1 approval from reviewers with write access.

Why this tier
  • Adds 1 file(s), e.g. skills/pester-migration/references/verifying-a-migration.md
  • Changes 289 lines (low-risk limit is 40)

Automated checks

Check Status Details
Line endings ✅ Passed Passed · logs
Spelling ✅ Passed Passed · logs
Generated README consistency ❌ Contribution failure Failed step: Fail workflow if files need updating · logs
Skill validation ✅ Passed Passed · logs
Skill lint (vally) ✅ Passed Passed · logs
Risk scan ✅ Passed Passed · logs
Contributor reputation ✅ Passed Passed · logs
Duplicate resource scan ✅ Passed Passed · logs
PR quality signal ⏭️ Skipped Skipped by its workflow · logs

Action needed

  • Generated README consistency failed. Run npm start locally and commit the regenerated files.

Review

  • Approvals: 0/1
  • Assigned reviewer: not assigned yet — comment /request-review to ask for one
  • Review target date: not set
  • Still needed: 1 more approval(s)
  • No staffed reviewer pool owns these files yet; any reviewer with write access counts as the domain reviewer.

Commands

Command Who What it does
/rerun-checks PR author, maintainers Re-runs failed or incomplete checks and re-evaluates this gate
/request-review PR author, maintainers Asks the review rotation to assign a reviewer (adds needs-reviewer)

Updated for eb82bc0 · gate run · This comment is maintained automatically — see submission gate docs.

@github-actions

github-actions Bot commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

🔍 Vally Lint Results

✅ All checks passed

Scope Checked
Skills 1
Agents 0
Total 1
Severity Count
❌ Errors 0
⚠️ Warnings 0
ℹ️ Advisories 0

Summary

Level Finding
ℹ️ ✅ pester-migration (2/2 checks passed)
ℹ️ ✓ [spec-compliance] All 1 skill(s) are spec-compliant.
ℹ️ ✓ spec-compliance: All spec checks passed.
ℹ️ ✓ [valid-refs] All file references across 1 skill(s) are valid.
ℹ️ ✓ valid-refs: All file references resolve to existing files within the skill directory.
ℹ️ 1 skill(s) linted, 1 passed
Full linter output
### Linting skills/pester-migration
✅ pester-migration (2/2 checks passed)
    ✓ [spec-compliance] All 1 skill(s) are spec-compliant.
        ✓ spec-compliance: All spec checks passed.
    ✓ [valid-refs] All file references across 1 skill(s) are valid.
        ✓ valid-refs: All file references resolve to existing files within the skill directory.

1 skill(s) linted, 1 passed

@github-actions github-actions Bot added requires-submitter-fixes Submission has quality-gate findings that submitter must fix before maintainer review and removed awaiting-automation labels Dec 6, 2026

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.

🟡 Changes recommended

The verification guidance can let failed Pester runs exit successfully, while duplicate-key overwrites and inconsistent hierarchy encoding make test comparisons unreliable.

3 open issues
What changed in this PR

Strengthens the pester-migration skill with verification guidance to detect silent test loss and migration regressions.

Changes:

  • Adds baseline capture and test-by-test comparison examples.
  • Documents CI failure checks and Discovery-time mock hazards.
  • Updates the migration workflow and v4→v5 checklist.
File Description
skills/​pester-migration/​SKILL.md Links the reference and strengthens verification and safety steps.
skills/​pester-migration/​references/​verifying-a-migration.md Adds comparison scripts, CI guidance, and migration pitfalls.
skills/​pester-migration/​references/​v4-to-v5.md Adds a Discovery warning and verification checklist items.

Review effort: Balanced (adaptive)


```powershell
if ('Passed' -ne $result.Result) {
Write-Error "Pester run result was '$($result.Result)', with $($result.FailedCount) failed tests."
Comment on lines +48 to +49
$chain = @($test.Describe, $test.Context, $test.Name) | Where-Object { $_ }
[pscustomobject]@{ Path = ($chain -join ' > '); Result = $test.Result }
Comment on lines +76 to +77
$before = @{}; Import-Csv .\before.csv | ForEach-Object { $before[$_.Path] = $_.Result }
$after = @{}; Import-Csv .\after.csv | ForEach-Object { $after[$_.Path] = $_.Result }

This branch has not been deployed

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

Labels

merge-risk:medium requires-submitter-fixes Submission has quality-gate findings that submitter must fix before maintainer review skills PR touches skills

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants