Skip to content

Test discovery fails: pinned Pester 5.7.1 conflicts with installed Pester 5.8.0 #15

Description

Summary

The Test-* jobs in the latest Process-PSModule run fail during Pester discovery, so main CI is red. No tests actually execute (TotalCount = 0); the container fails before discovery completes.

Error

[-] Discovery in .../tests/PSCustomObject.Tests.ps1 failed with:
System.IO.FileLoadException: Could not load file or assembly 'Pester, Version=5.7.1.0, Culture=neutral, PublicKeyToken=null'. Assembly with same name is already loaded
   at Invoke-BlockContainer, .../Modules/Pester/5.8.0/Pester.psm1: line 3008

Root cause

The test files pin an exact Pester version:

#Requires -Modules @{ ModuleName = 'Pester'; RequiredVersion = '5.7.1' }

The PSModule/Invoke-Pester action now installs and imports the latest Pester (5.8.0) before discovery. When discovery evaluates the #Requires with RequiredVersion = '5.7.1', PowerShell attempts to load the 5.7.1 assembly while 5.8.0 is already loaded in the session, which throws FileLoadException. This is a container/discovery-level failure, so every Test-* job fails.

Affected files

  • tests/PSCustomObject.Tests.ps1

Fix

Remove the exact-version pin line from the affected test file(s):

-#Requires -Modules @{ ModuleName = 'Pester'; RequiredVersion = '5.7.1' }

This matches PSModule/Template-PSModule and the other module repos, whose test files carry no Pester #Requires pin and pass on Pester 5.8.0. The Invoke-Pester action controls the Pester version centrally, so per-repo exact-version pinning is unnecessary and causes this drift whenever Pester releases a new version.

Reference

Failing run: https://github.com/PSModule/PSCustomObject/actions/runs/28724777021

Activity

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions