From 2f69bf6e1a1d2aecc5f4c074b486636ffb16e702 Mon Sep 17 00:00:00 2001 From: Eduard Arbona <175124143+earbona23@users.noreply.github.com> Date: Sun, 15 Nov 2026 13:03:25 -0400 Subject: [PATCH] fix(tests): Golden.Tests.ps1 imports the module it reaches into Golden.Tests.ps1 reaches into the module with InModuleScope Maester but never imports it, so it passes only when another test file in the same run imported it first. Run on its own it fails with "No modules named 'Maester' are currently loaded". Measured on main at 2d659e8: Golden.Tests.ps1 alone, as it is: 12 passed, 1 failed -> No modules named 'Maester' are currently loaded. Golden.Tests.ps1 alone, with this: 13 passed, 0 failed CI never saw it, because it runs every file in one invocation where something else has already imported the module. The cost falls on a contributor who follows AGENTS.md - add a built-in test, run the exporter, then run this file to check the fixtures - and meets a failure that has nothing to do with the change being made. One line, in the form the other 98 test files use. It does not disturb a combined run: this file together with AttributeReview, NativeTestAttributes and Test-MtCaEmergencyAccessExists in a single Invoke-Pester gives 93 of 93. --- powershell/tests/functions/golden/Golden.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/powershell/tests/functions/golden/Golden.Tests.ps1 b/powershell/tests/functions/golden/Golden.Tests.ps1 index 744d5aebe5..198aaac499 100644 --- a/powershell/tests/functions/golden/Golden.Tests.ps1 +++ b/powershell/tests/functions/golden/Golden.Tests.ps1 @@ -12,6 +12,9 @@ Describe 'Maester 2.x golden fixtures' -Tag 'Golden' { BeforeAll { + # The tag context below reaches into the module with InModuleScope, so this file needs the module + # loaded. Without this it passes only when another test file in the same run imported it first. + Import-Module $PSScriptRoot/../../../Maester.psd1 -Force $repoRoot = (Resolve-Path "$PSScriptRoot/../../../..").Path $goldenRoot = Join-Path $repoRoot 'powershell/tests/fixtures/golden' $exporter = Join-Path $repoRoot 'build/golden/Export-MtGoldenFixture.ps1'