Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bergmeister opened this issue Jan 21, 2019 · 3 comments
Labels
Area-Debugging Issue-Enhancement A feature request (enhancement).

Comments

@bergmeister
Copy link
Contributor

bergmeister commented Jan 21, 2019

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

@rjmholt
Copy link
Contributor

rjmholt commented Jan 22, 2019

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

The logic we use to load the right PSSA uses Get-Module -ListAvailable.

We then just check the version of the PSModuleInfo against what we want.

@TylerLeonhardt
Copy link
Member

We have this feature now thanks to @bergmeister and @rkeithhill!

@bergmeister
Copy link
Contributor Author

Yes, sorry, I forgot to close the issue

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Aug 19, 2019
@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Debugging Issue-Enhancement A feature request (enhancement).
Projects
None yet
4 participants