Skip to content

Migrating from 4.10 to 5.x and handling -Skip #2284

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

You must be logged in to vote

Hi, that's a good question!

-Skip is evaluated as part of Discovery (see https://pester.dev/docs/usage/skip#conditional-skip). Ideally you'd run some code in BeforeDiscovery to figure out if you need them or not.

If that's not possible then you'd have to use Set-ItResult to skip. You will have to use a script-scoped (or worst case global) variable to share the variable between It-blocks.

$script:-scope is normally per *.tests.ps1-file unless you run code inside a module function or something like InModuleScope SomeModule { .. }. Remember to use unique variable names and/or clear it when it shouldn't apply anymore, ex. in a AfterAll. Especially with global-variable that would affect the ne…

Replies: 1 comment 1 reply

Comment options

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

Answer selected by fflaten
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