Prerequisites
Before building anything, let's make sure the tools are in place. This page is short, but the version check at the end matters more than it looks — a surprising number of confusing Pester problems turn out to be "you are running an older version than you think".
PowerShell
Pester v6 runs on:
- Windows PowerShell 5.1, or
- PowerShell 7.4 or newer
Check what you have:
$PSVersionTable.PSVersion
If you are on PowerShell 7 but older than 7.4, install a current release from the PowerShell repository. This tutorial works on Windows, macOS and Linux.
Installing Pester
Install from the PowerShell Gallery:
Install-Module -Name Pester -Force
On Windows you may already have Pester 3.4.0 installed — it ships with the operating system. That version cannot be updated in place, and it is different enough from v6 that following this tutorial with it will not work. If Install-Module complains about an existing installation, the installation guide covers the exact commands to get around it.
Confirming the version
Import the module using -PassThru so we can verify the version you have available.
Import-Module Pester -PassThru
ModuleType Version PreRelease Name
---------- ------- ---------- ----
Script 6.0.0 Pester
If the version shown starts with a 6, you are ready.
PowerShell loads a module automatically the first time you call one of its commands, and it picks the highest version it can find — but if an older Pester is already loaded in your session, it stays loaded. If the version above is not what you expect, open a fresh PowerShell session and check again before doing anything else.
An editor
You'll need a text editor to edit the scripts and test files. This tutorial will use the terminal to run tests, so any text editor will work.
For new users, we recommend Visual Studio Code with the PowerShell extension for the best experience: it discovers your tests as you write them and lets you run or debug a single test without leaving the file. See VS Code page for more details.
A folder to work in
Create somewhere to build the module and move into it:
New-Item -Path ./pester-tutorial -ItemType Directory
Set-Location ./pester-tutorial
Every path in this tutorial is relative to that folder.
Before you move on
0/4That is the setup done. Next you will create the Planetarium module itself.