pester

Write, organize, and run Pester tests for PowerShell projects.

16|1|Updated Oct 3, 2023
One-click install
npx skills add https://github.com/OleksandrKucherenko/e-bash --skill pester
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pester
Source: https://github.com/OleksandrKucherenko/e-bash/tree/main/.claude/skills/pester
Command: npx skills add https://github.com/OleksandrKucherenko/e-bash --skill pester

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Pester is a framework that guides you to write, structure, and run PowerShell unit tests, mocks, and verification patterns efficiently.

Core Features & Use Cases

  • Guidance on test structure (Describe/Context/It), two-phase Discovery vs Run, and best practices
  • Mocking patterns for PowerShell commands, native tools, and CI-friendly test reporting
  • Integration tips for TestDrive/TestRegistry, code coverage, and CI pipelines

Quick Start

Install the Pester module, create a simple test file named Example.Tests.ps1 with Describe and It blocks, and run Invoke-Pester to execute tests.

Frequently Asked Questions about pester

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure PowerShell unit tests using Describe and Context blocks?

Structure PowerShell unit tests by nesting Context blocks within Describe blocks to group related test cases. This organization clarifies test scenarios and scopes mocking behavior effectively within your Pester test suite.

What is the two-phase discovery and run process in PowerShell testing?

The two-phase discovery and run process in PowerShell testing first scans test files to collect Describe blocks, then executes the tests. This separation ensures accurate test enumeration before running, preventing discovery errors from halting execution.

How do I mock PowerShell commands and native tools in unit tests?

Mock PowerShell commands and native tools in unit tests by replacing their behavior with controlled outputs using Mock. This isolates the code under test, ensuring CI pipelines validate logic without triggering actual system changes.

Can I integrate PowerShell test results and code coverage into CI pipelines?

Yes, you can integrate PowerShell test results and code coverage into CI pipelines. Configure test reporting to output structured formats, enabling automated CI systems to parse results and track code coverage metrics.

How do TestDrive and TestRegistry work for PowerShell test isolation?

TestDrive and TestRegistry provide temporary file system and registry locations for PowerShell test isolation. They automatically create and tear down these sandboxes, ensuring tests do not leave residual state on the machine.

Why are my Pester tests failing to discover correctly in a PowerShell project?

Pester tests fail to discover correctly in a PowerShell project when syntax errors or improper block nesting exist during the discovery phase. Ensure your Describe and It blocks are structured properly to avoid discovery failures.