@@ -39,23 +39,26 @@ applyTo: "**/*.[Tt]ests.ps1"
3939
4040## Syntax Rules
4141- PascalCase: ` Describe ` , ` Context ` , ` It ` , ` Should ` , ` BeforeAll ` , ` BeforeEach ` , ` AfterAll ` , ` AfterEach `
42- - Use ` -BeTrue ` /` -BeFalse ` never ` -Be $true ` /` -Be $false `
42+ - Use ` -BeTrue ` /` -BeFalse ` never ` -Be $true ` /` -Be $false ` / ` -Contain $true ` / ` -Contain $false `
4343- Never use ` Assert-MockCalled ` , use ` Should -Invoke ` instead
4444- No ` Should -Not -Throw ` - invoke commands directly
4545- Never add an empty ` -MockWith ` block
4646- Omit ` -MockWith ` when returning ` $null `
4747- Set ` $PSDefaultParameterValues ` for ` Mock:ModuleName ` , ` Should:ModuleName ` , ` InModuleScope:ModuleName `
4848- Omit ` -ModuleName ` parameter on Pester commands
4949- Never use ` Mock ` inside ` InModuleScope ` -block
50- - Never use ` param() ` inside ` -MockWith ` scriptblocks, parameters are auto-bound
50+ - Never use ` param() ` -block inside ` -MockWith ` scriptblocks, parameters are auto-bound
51+ - In ` InModuleScope ` tests, add ` Set-StrictMode -Version 1.0 ` immediately before invoking the tested function
52+ - Use ` Should -Invoke -Exactly -Times <n> -Scope It ` for call-count assertions
53+ - Assert <n > calls inside the ` It ` block; do not assert call counts across an entire ` Describe ` or ` Context `
5154
5255## File Organization
5356- Class resources: ` tests/Unit/Classes/{Name}.Tests.ps1 `
5457- Public commands: ` tests/Unit/Public/{Name}.Tests.ps1 `
5558- Private functions: ` tests/Unit/Private/{Name}.Tests.ps1 `
5659
5760## Data-Driven Tests (Test Cases)
58- - Define ` -ForEach ` variables in ` BeforeDiscovery ` (close to usage)
61+ - Define ` -ForEach ` variables in separate ` BeforeDiscovery ` (close to usage)
5962- ` -ForEach ` allowed on ` Context ` and ` It ` blocks
6063- Never add ` param() ` inside Pester blocks when using ` -ForEach `
6164- Access test case properties directly: ` $PropertyName `
0 commit comments