Open fflaten opened 1 month ago
Good or checking too many places? Can we improve the error somehow? Included a truncated scriptblock string to help identity the source.
Update link to https://pester.dev/docs/migrations/v5-to-v6 (when available) with workaround?
PR Summary
Throws when user provides scriptblocks that are not bound to a session state. They would be executed in Pester's module state which could cause unexpected behaviour.
Examples:
Fix #2411
Checklist:
Add-AssertionOperator -Test
(type:ScriptBlock
)Add-ShouldOperator -Test
(type:ScriptBlock
)AfterAll -Scriptblock
(type:ScriptBlock
)AfterEach -Scriptblock
(type:ScriptBlock
)BeforeAll -Scriptblock
(type:ScriptBlock
)BeforeDiscovery -ScriptBlock
(type:ScriptBlock
)BeforeEach -Scriptblock
(type:ScriptBlock
)Context -Fixture
(type:ScriptBlock
)Describe -Fixture
(type:ScriptBlock
)InModuleScope -ScriptBlock
(type:ScriptBlock
)It -Test
(type:ScriptBlock
)Mock -MockWith
(type:ScriptBlock
)Mock -ParameterFilter
(type:ScriptBlock
)New-PesterContainer -ScriptBlock
(type:ScriptBlock[]
)Should-All -FilterScript
(type:ScriptBlock
)Should-Any -FilterScript
(type:ScriptBlock
)Should-Throw -ScriptBlock
(type:ScriptBlock
)Run.Scriptblock
Run.Container
PR Checklist
Create Pull Request
to mark it as a draft. PR can be markedReady for review
when it's ready.