@@ -40,12 +40,12 @@ if ($hasClassExporter) {
4040 $expectedEnumNames = @ ([regex ]::Matches($Matches [1 ], ' \[([^\]]+)\]' ) | ForEach-Object { $_.Groups [1 ].Value })
4141 }
4242}
43- Write-Host " Has class exporter: $hasClassExporter "
44- Write-Host " Expected classes: $ ( $expectedClassNames -join ' , ' ) "
45- Write-Host " Expected enums: $ ( $expectedEnumNames -join ' , ' ) "
4643
47- # Run-phase setup — recompute from $Path (available in both Discovery and Run phases).
48- # Script-level variables above only exist during Discovery; BeforeAll runs only during Run.
44+
45+ # Run-phase setup — recompute from $Path so that It/Context blocks can use these variables.
46+ # Pester v5 Discovery and Run are separate executions. The script-scope variables above drive
47+ # -Skip and -ForEach during Discovery. This BeforeAll recomputes the same values for the Run
48+ # phase, where It blocks actually execute. The duplication is intentional and required.
4949BeforeAll {
5050 $moduleName = Split-Path - Path (Split-Path - Path $Path - Parent) - Leaf
5151 $moduleManifestPath = Join-Path - Path $Path - ChildPath " $moduleName .psd1"
@@ -64,9 +64,9 @@ BeforeAll {
6464 $expectedEnumNames = @ ([regex ]::Matches($Matches [1 ], ' \[([^\]]+)\]' ) | ForEach-Object { $_.Groups [1 ].Value })
6565 }
6666 }
67- Write-Host " Run phase - Module : $moduleName "
68- Write-Host " Run phase - Manifest: $moduleManifestPath "
69- Write-Host " Run phase - Has class exporter: $hasClassExporter "
67+ Write-Host " Has class exporter : $hasClassExporter "
68+ Write-Host " Expected classes: $ ( $expectedClassNames -join ' , ' ) "
69+ Write-Host " Expected enums: $ ( $expectedEnumNames -join ' , ' ) "
7070}
7171
7272Describe ' PSModule - Module tests' {
0 commit comments