Can It blocks be used in BeforeAll/BeforeEach etc? #2132
-
Say you want to have an It test that your module loads. But you're also loading the module in the BeforeAll block. Can you wrap it in an It there? I could not find a definitive list of what blocks are allowed to be nested inside each other. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You should not, it won't find the test, technically it is possible because tests run after BeforeAll. But having at least one test in the respective block is a pre-condition to run a BeforeAll at all. So even though I can make it work easily it by changing the internal test tree from BeforeAll, I did not pursue this idea further. So it is not supported and won't find your test. Invoke-Pester -Container (New-PesterContainer -ScriptBlock {
Describe "a" {
BeforeAll {
It "a" {}
}
It "b" {}
}
}) -Output Detailed
|
Beta Was this translation helpful? Give feedback.
You should not, it won't find the test, technically it is possible because tests run after BeforeAll. But having at least one test in the respective block is a pre-condition to run a BeforeAll at all. So even though I can make it work easily it by changing the internal test tree from BeforeAll, I did not pursue this idea further. So it is not supported and won't find your test.