Skip to content

InPesterModuleScope may be redundant, InModuleScope -ModuleName Pester appears to work #3002

Description

@nohwnd

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.

🤖

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions