Skip to content

Is there a way to determine what tags are included/excluded at run time? Or mock based on tags? #2322

Answered by fflaten
briantist asked this question in Q&A
Discussion options

You must be logged in to vote

Checking configuration at runtime will depend on #318.
If you don't mind relying on internal API that will likely change (ex. the variable name when made public), then you can use:

$____Pester.Configuration.Filter.Tag.Value
$____Pester.Configuration.Filter.ExcludeTag.Value

Supported workaround:
You can use container/script Data to set a variable, ex.

$containers = New-PesterContainer -Path '/workspaces/Pester/Samples/' -Data @{ RunAsUnitTests = $true }
# Set in Run.Container if using Advanced Configuration

Invoke-Pester -Container $containers -Output Detailed

$RunAsUnitTests would then be available in both Discovery and Run-phase.

If your testsfiles define it as a parameter as well, ex. p…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@briantist
Comment options

Answer selected by briantist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants