test.ps1 defines its own InPesterModuleScope in the TestHelpers module, with this reason:
# add our own in module scope because the implementation
# pester relies on being in different sesstion state than
# the module scope target
It is used 67 times across tst/, while InModuleScope -ModuleName Pester is used 12 times, so both are in play.
I could not reproduce the stated reason. InModuleScope -ModuleName Pester { (Get-Command Get-TracerPoint).Name } reached an internal command both outside a run and at discovery time inside a run (top level of a test file, wrapping Describe), which is the shape the 67 call sites use. The helper dates to 6ceec22 (Move sources to new structure, April 2020), so the constraint may have been real then and fixed since.
Not a conclusion. I only tried the two straightforward shapes and did not convert a real file and run it, so there may be a case that still needs the dot-source. Worth someone checking, because if it is obsolete then TestHelpers shrinks to New-Dictionary / Clear-WhiteSpace and one less thing has to be reproduced for any session that runs a test file outside test.ps1.
🤖
test.ps1defines its ownInPesterModuleScopein theTestHelpersmodule, with this reason:It is used 67 times across
tst/, whileInModuleScope -ModuleName Pesteris used 12 times, so both are in play.I could not reproduce the stated reason.
InModuleScope -ModuleName Pester { (Get-Command Get-TracerPoint).Name }reached an internal command both outside a run and at discovery time inside a run (top level of a test file, wrappingDescribe), which is the shape the 67 call sites use. The helper dates to6ceec22(Move sources to new structure, April 2020), so the constraint may have been real then and fixed since.Not a conclusion. I only tried the two straightforward shapes and did not convert a real file and run it, so there may be a case that still needs the dot-source. Worth someone checking, because if it is obsolete then
TestHelpersshrinks toNew-Dictionary/Clear-WhiteSpaceand one less thing has to be reproduced for any session that runs a test file outsidetest.ps1.🤖