From 1c5f8647e139515fd7716ab4939a04b4f7a9bd22 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 7 Jul 2026 16:45:52 +0200 Subject: [PATCH 1/3] Document the Pester major-version lock for test files --- src/docs/PowerShell/Modules/Test-Specification.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/docs/PowerShell/Modules/Test-Specification.md b/src/docs/PowerShell/Modules/Test-Specification.md index d08eb9b..e074bd7 100644 --- a/src/docs/PowerShell/Modules/Test-Specification.md +++ b/src/docs/PowerShell/Modules/Test-Specification.md @@ -4,6 +4,18 @@ This document defines the structure and guidelines for writing Pester tests for PowerShell functions. The goal is to ensure consistency and comprehensive test coverage while maintaining clarity. +## Pester version + +Lock the test framework to a **major version** so a new Pester major cannot be adopted silently and break every suite at once. Declare it as the first line of each `*.Tests.ps1` file: + +```powershell +#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '6.0.0'; MaximumVersion = '6.999.999'; GUID = 'a699dea5-2c73-4616-a270-1f7abb777e71' } +``` + +- `ModuleVersion` + `MaximumVersion` accept any Pester `6.x`, so routine minor and patch updates flow in without a change here — only a new major requires a deliberate, reviewed bump. +- The `GUID` pins module identity (a name alone can be squatted). PowerShell enforces both the version range and the GUID at discovery time. +- The [Invoke-Pester](https://github.com/PSModule/Invoke-Pester) action installs a matching `6.x`, so the requirement and the installed version stay aligned. + ## Test Structure Each function is tested within a structured Pester `Describe` block that follows this hierarchy: From 318b4cc7c7c43d2a84bb977988fd599fead55253 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 7 Jul 2026 17:37:15 +0200 Subject: [PATCH 2/3] Use the 6.* wildcard for the Pester major-version ceiling --- src/docs/PowerShell/Modules/Test-Specification.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docs/PowerShell/Modules/Test-Specification.md b/src/docs/PowerShell/Modules/Test-Specification.md index e074bd7..92db96e 100644 --- a/src/docs/PowerShell/Modules/Test-Specification.md +++ b/src/docs/PowerShell/Modules/Test-Specification.md @@ -9,7 +9,7 @@ This document defines the structure and guidelines for writing Pester tests for Lock the test framework to a **major version** so a new Pester major cannot be adopted silently and break every suite at once. Declare it as the first line of each `*.Tests.ps1` file: ```powershell -#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '6.0.0'; MaximumVersion = '6.999.999'; GUID = 'a699dea5-2c73-4616-a270-1f7abb777e71' } +#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '6.0.0'; MaximumVersion = '6.*'; GUID = 'a699dea5-2c73-4616-a270-1f7abb777e71' } ``` - `ModuleVersion` + `MaximumVersion` accept any Pester `6.x`, so routine minor and patch updates flow in without a change here — only a new major requires a deliberate, reviewed bump. From 31be15ef588df682c1fd40ff4629f2924b02ac41 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 7 Jul 2026 21:16:15 +0200 Subject: [PATCH 3/3] Drop the GUID from the Pester requirement example --- src/docs/PowerShell/Modules/Test-Specification.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/docs/PowerShell/Modules/Test-Specification.md b/src/docs/PowerShell/Modules/Test-Specification.md index 92db96e..870e3f7 100644 --- a/src/docs/PowerShell/Modules/Test-Specification.md +++ b/src/docs/PowerShell/Modules/Test-Specification.md @@ -9,12 +9,13 @@ This document defines the structure and guidelines for writing Pester tests for Lock the test framework to a **major version** so a new Pester major cannot be adopted silently and break every suite at once. Declare it as the first line of each `*.Tests.ps1` file: ```powershell -#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '6.0.0'; MaximumVersion = '6.*'; GUID = 'a699dea5-2c73-4616-a270-1f7abb777e71' } +#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '6.0.0'; MaximumVersion = '6.*' } ``` - `ModuleVersion` + `MaximumVersion` accept any Pester `6.x`, so routine minor and patch updates flow in without a change here — only a new major requires a deliberate, reviewed bump. -- The `GUID` pins module identity (a name alone can be squatted). PowerShell enforces both the version range and the GUID at discovery time. +- The `MaximumVersion = '6.*'` wildcard locks to the major without a sentinel version; PowerShell enforces the range at discovery time. - The [Invoke-Pester](https://github.com/PSModule/Invoke-Pester) action installs a matching `6.x`, so the requirement and the installed version stay aligned. +- Pinning module identity with a `GUID` is a separate, stricter supply-chain control — omit it for the default major-lock; add it only when identity assurance is required. ## Test Structure