Skip to content

Execute Pester Describe block using interpolated string using new Pester 4.6 parameter #1710

Closed
@bergmeister

Description

@bergmeister

Summary of the new feature

As a result of discussing issue #827, this PR added a Pester option for specifying the line instead of a test name, this means that this enables us to run Pester tests that contain interpolated describe block strings. However, we cannot just simply change the syntax because we cannot rely on the latest version of Pester being installed. This outlines the high level behaviour

Proposed technical implementation details (optional)

  • PSES should additionally send the line number (pesterSymbol.ScriptRegion.StartLineNumber) to the vscode extension here and here.
  • In the extension we need to make a decision then based on the Pester version number to determine the syntax to Invoke-Pester:
    • I propose to use (Get-Module -ListAvailable Pester).Version | Sort-Object -Descending | Select-Object -First 1 to retrieve the latest version. The first time it takes ~250ms, after that it's ~50ms. Should we cache the version or just always check? Or I should I do this expensive work at startup in the background? Although Get-Module has better performance compared to Get-Command, the check is not 100% accurate because one can technically import an older specific version of Pester via Import-Module and at runtime this older version would be used. Please respond and discuss this point
    • If the Pester version is determined to be too old, then the extension should fall back to the existing behaviour whereby it asks the user if he/she wants to Invoke-Pester just against the whole file.
    • Where is the best way of checking the version? Should we do this in PSES by calling into the PS API or should we pre-pend code before the Invoke-Pester call in the extension? IF PSES has the info, then I guess we would also send another boolean parameter to the extension whether to use the describeblockname or the describeblocknumber?

cc @rkeithhill @TylerLeonhardt @rjmholt for discussion

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions