/vibe:ghcopilot-instr-powershell-pester-5from vibe
Provides Pester v5 testing patterns for PowerShell: file naming, test hierarchy, assertions, mocking, and setup/teardown. Useful when writing or reviewing .Tests.ps1 files.
Ships in vibe. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This guide provides PowerShell-specific instructions for creating automated tests using PowerShell Pester v5 module. Follow PowerShell cmdlet development guidelines in powershell.instructions.md for general PowerShell scripting best practices.
*.Tests.ps1 naming patternBeforeAll { . $PSScriptRoot/FunctionName.ps1 } to import tested functionsBeforeAll, Describe, Context, It, etc.)BeforeAll { # Import tested functions }
Describe 'FunctionName' {
Context 'When condition' {
BeforeAll { # Setup for context }
It 'Should behavior' { # Individual test }
AfterAll { # Cleanup for context }
}
}
Describe: Top-level grouping, typically named after function being testedContext: Sub-grouping within Describe for specific scenariosIt: Individual test cases, use descriptive namesShould: Assertion keyword for test validationBeforeAll/AfterAll: Setup/teardown once per blockBeforeEach/AfterEach: Setup/teardown before/after each testBeforeAll: Runs once at start of containing block, use for expensive operationsBeforeEach: Runs before every It in block, use for test-specific setupAfterEach: Runs after every It, guaranteed even if test failsAfterAll: Runs once at end of block, use for cleanupBeforeAll variables available to child blocks (read-only), BeforeEach/It/AfterEach share same scope-Be, -BeExactly, -Not -Be-Contain, -BeIn, -HaveCount-BeGreaterThan, -BeLessThan, -BeGreaterOrEqual-Match, -Like, -BeNullOrEmpty-BeOfType, -BeTrue, -BeFalse-Exist, -FileContentMatch-Throw, -Not -ThrowMock CommandName { ScriptBlock }: Replace command behavior-ParameterFilter: Mock only when parameters match condition-Verifiable: Mark mock as requiring verificationShould -Invoke: Verify mock was called specific number of timesShould -InvokeVerifiable: Verify all verifiable mocks were calledMock Get-Service { @{ Status = 'Running' } } -ParameterFilter { $Name -eq 'TestService' }
Should -Invoke Get-Service -Exactly 1 -ParameterFilter { $Name -eq 'TestService' }
Use -TestCases or -ForEach for parameterized tests:
It 'Should return <Expected> for <Input>' -TestCases @(
@{ Input = 'value1'; Expected = 'result1' }
@{ Input = 'value2'; Expected = 'result2' }
) {
Get-Function $Input | Should -Be $Expected
}
-ForEach: Available on Describe, Context, and It for generating multiple tests from data-TestCases: Alias for -ForEach on It blocks (backwards compatibility)@{ Name = 'value'; Expected = 'result' })$_ variable for current item<variablename> in test names for dynamic expansion# Hashtable approach
It 'Returns <Expected> for <Name>' -ForEach @(
@{ Name = 'test1'; Expected = 'result1' }
@{ Name = 'test2'; Expected = 'result2' }
) { Get-Function $Name | Should -Be $Expected }
# Array approach
It 'Contains <_>' -ForEach 'item1', 'item2' { Get-Collection | Should -Contain $_ }
Describe, Context, and It blocks-TagFilter and -ExcludeTagFilter with Invoke-Pester-like wildcards for flexible filteringDescribe 'Function' -Tag 'Unit' {
It 'Should work' -Tag 'Fast', 'Stable' { }
It 'Should be slow' -Tag 'Slow', 'Integration' { }
}
# Run only fast unit tests
Invoke-Pester -TagFilter 'Unit' -ExcludeTagFilter 'Slow'
-Skip: Available on Describe, Context, and It to skip tests-Skip:$condition for dynamic skippingSet-ItResult -Skipped during test execution (setup/teardown still run)It 'Should work on Windows' -Skip:(-not $IsWindows) { }
Context 'Integration tests' -Skip { }
Should.ErrorAction = 'Continue' to collect multiple failures-ErrorAction Stop for pre-conditions{ Code } | Should -Throw for exception testingWhere-Object not ?)BeforeAll {
. $PSScriptRoot/Get-UserInfo.ps1
}
Describe 'Get-UserInfo' {
Context 'When user exists' {
BeforeAll {
Mock Get-ADUser { @{ Name = 'TestUser'; Enabled = $true } }
}
It 'Should return user object' {
$result = Get-UserInfo -Username 'TestUser'
$result | Should -Not -BeNullOrEmpty
$result.Name | Should -Be 'TestUser'
}
It 'Should call Get-ADUser once' {
Get-UserInfo -Username 'TestUser'
Should -Invoke Get-ADUser -Exactly 1
}
}
Context 'When user does not exist' {
BeforeAll {
Mock Get-ADUser { throw "User not found" }
}
It 'Should throw exception' {
{ Get-UserInfo -Username 'NonExistent' } | Should -Throw "*not found*"
}
}
}
Configuration is defined outside test files when calling Invoke-Pester to control execution behavior.
# Create configuration (Pester 5.2+)
$config = New-PesterConfiguration
$config.Run.Path = './Tests'
$config.Output.Verbosity = 'Detailed'
$config.TestResult.Enabled = $true
$config.TestResult.OutputFormat = 'NUnitXml'
$config.Should.ErrorAction = 'Continue'
Invoke-Pester -Configuration $config
Key Sections: Run (Path, Exit), Filter (Tag, ExcludeTag), Output (Verbosity), TestResult (Enabled, OutputFormat), CodeCoverage (Enabled, Path), Should (ErrorAction), Debug
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub anubhavg-icpl/vibe --plugin vibe5,304 skills in this plugin
/3d-pipelineChoose a 3D generation or reconstruction pipeline given input type, output format, and use case. Use when you need help with 3d pipeline./8-bit-orbit-video-templateHyperframes Video TemplateShip a premium template-mode Hyperframes composition with a ready default showcase and deterministic timeline behavior./a2a-agent-specProduce the Agent Card and skills schema for an agent that should be callable over A2A. Use when you need help with a2a agent spec.Other plugins' skills for the same job