Skip to content

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

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/Context.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/Context.Tests.ps1
  • tests/ContextVaults.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/Context/actions/runs/28724387936

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugBroken functionality that fails or creates an unwanted outcome

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions