{"id":13448107,"url":"https://github.com/pester/Pester","last_synced_at":"2025-03-22T02:30:40.557Z","repository":{"id":1274229,"uuid":"1213474","full_name":"pester/Pester","owner":"pester","description":"Pester is the ubiquitous test and mock framework for PowerShell.","archived":false,"fork":false,"pushed_at":"2024-10-07T19:30:41.000Z","size":22322,"stargazers_count":3110,"open_issues_count":163,"forks_count":473,"subscribers_count":156,"default_branch":"main","last_synced_at":"2024-10-29T14:55:56.765Z","etag":null,"topics":["assertions","bdd","bdd-framework","mock","mocking","pester-tests","powershell","powershell-tests","tdd","tdd-framework","testing"],"latest_commit_sha":null,"homepage":"https://pester.dev/","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pester.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":"SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["nohwnd","fflaten"],"open_collective":"pester"}},"created_at":"2011-01-02T03:33:19.000Z","updated_at":"2024-10-28T14:02:41.000Z","dependencies_parsed_at":"2023-01-13T11:45:19.578Z","dependency_job_id":"ecceabf2-08ec-4d21-895e-e051fc4221f6","html_url":"https://github.com/pester/Pester","commit_stats":{"total_commits":1705,"total_committers":163,"mean_commits":"10.460122699386503","dds":0.6557184750733138,"last_synced_commit":"cb5d640f5229a4ea848eb48350ab628964d3ff02"},"previous_names":[],"tags_count":154,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pester%2FPester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pester%2FPester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pester%2FPester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pester%2FPester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pester","download_url":"https://codeload.github.com/pester/Pester/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244320411,"owners_count":20434092,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assertions","bdd","bdd-framework","mock","mocking","pester-tests","powershell","powershell-tests","tdd","tdd-framework","testing"],"created_at":"2024-07-31T05:01:35.837Z","updated_at":"2025-03-22T02:30:40.538Z","avatar_url":"https://github.com/pester.png","language":"PowerShell","readme":"# Pester\r\n\r\n\u003e 💵 Please consider sponsoring [nohwnd](https://github.com/sponsors/nohwnd), [fflaten](https://github.com/sponsors/fflaten) or sponsoring [Pester](https://opencollective.com/pester) itself.\r\n\r\n\u003e 🌵 Documentation is available at [https://pester.dev/docs/quick-start](https://pester.dev/docs/quick-start).\r\n\r\n\u003e 📦🔐 Pester is now signed. `-SkipPublisherCheck` should no longer be used to install from PowerShell Gallery on Windows 10.\r\n\r\n\u003e 📦🔐 Upgrading to 5.6.0 will show a \"certificate changed\" error, this is because a change in Root Certificate, and you have to specify `-SkipPublisherCheck` to update. [More info below.](#signing-certificates)\r\n\r\n\u003e 👩👨 We are looking for contributors! All issues labeled [help wanted](https://github.com/pester/Pester/labels/help%20wanted) are up for grabs. They further split up into [good first issue](https://github.com/pester/Pester/labels/good%20first%20issue) that are issues I hope are easy to solve. [Bad first issue](https://github.com/pester/Pester/labels/bad%20first%20issue) where I expect the implementation to be problematic or needs to be proposed and discussed beforehand. And the rest which is somewhere in the middle. If you decide to pick up an issue please comment in the issue thread so others don't waste their time working on the same issue as you.\r\n\u003e There is also [contributor's guide](https://pester.dev/docs/contributing/introduction) that will hopefully help you.\r\n\r\nPester is the ubiquitous test and mock framework for PowerShell.\r\n\r\n```powershell\r\nBeforeAll {\r\n    # your function\r\n    function Get-Planet ([string]$Name='*')\r\n    {\r\n        $planets = @(\r\n            @{ Name = 'Mercury' }\r\n            @{ Name = 'Venus'   }\r\n            @{ Name = 'Earth'   }\r\n            @{ Name = 'Mars'    }\r\n            @{ Name = 'Jupiter' }\r\n            @{ Name = 'Saturn'  }\r\n            @{ Name = 'Uranus'  }\r\n            @{ Name = 'Neptune' }\r\n        ) | foreach { [PSCustomObject]$_ }\r\n\r\n        $planets | where { $_.Name -like $Name }\r\n    }\r\n}\r\n\r\n# Pester tests\r\nDescribe 'Get-Planet' {\r\n  It \"Given no parameters, it lists all 8 planets\" {\r\n    $allPlanets = Get-Planet\r\n    $allPlanets.Count | Should -Be 8\r\n  }\r\n\r\n  Context \"Filtering by Name\" {\r\n    It \"Given valid -Name '\u003cFilter\u003e', it returns '\u003cExpected\u003e'\" -TestCases @(\r\n      @{ Filter = 'Earth'; Expected = 'Earth' }\r\n      @{ Filter = 'ne*'  ; Expected = 'Neptune' }\r\n      @{ Filter = 'ur*'  ; Expected = 'Uranus' }\r\n      @{ Filter = 'm*'   ; Expected = 'Mercury', 'Mars' }\r\n    ) {\r\n      param ($Filter, $Expected)\r\n\r\n      $planets = Get-Planet -Name $Filter\r\n      $planets.Name | Should -Be $Expected\r\n    }\r\n\r\n    It \"Given invalid parameter -Name 'Alpha Centauri', it returns `$null\" {\r\n      $planets = Get-Planet -Name 'Alpha Centauri'\r\n      $planets | Should -Be $null\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nSave this code example in a file named `Get-Planet.Tests.ps1`, and run `Invoke-Pester Get-Planet.Tests.ps1`, or just press `F5` in VSCode.\r\n\r\nLearn how to [start quick with Pester](https://pester.dev/docs/quick-start) in our docs.\r\n\r\nThe example above also has an [annotated and production ready version here](docs/Examples/Planets).\r\n\r\n## Installation\r\n\r\nPester runs on Windows, Linux, MacOS and anywhere else thanks to PowerShell. It is compatible with Windows PowerShell 5.1 and PowerShell 7.2 and newer.\r\n\r\nPester 3 comes pre-installed with Windows 10, but we recommend updating, by running this PowerShell command _as administrator_:\r\n\r\n```powershell\r\nInstall-Module -Name Pester -Force\r\n```\r\n\r\nNot running Windows 10 or facing problems? See the [full installation and update guide](https://pester.dev/docs/introduction/installation).\r\n\r\n## Signing certificates\r\n\r\nThe certificate used for signing the code has changed in 5.6.0. Error is shown when updating the module.\r\nBelow is the list of the certificates you can expect to be used when importing the module (going back to 2016)\r\n\r\nVersion|Authority|Thumbprint\r\n---|---|---\r\n6.0.0-alpha4+|`CN=DigiCert Trusted G4 Code Signing RSA4096 SHA384 2021 CA1, O=\"DigiCert, Inc.\", C=US`|`147C2FD397677DC76DD198E83E7D9D234AA59D1A`\r\n5.6.0+|`CN=DigiCert Trusted G4 Code Signing RSA4096 SHA384 2021 CA1, O=\"DigiCert, Inc.\", C=US`|`2FCC9148EC2C9AB951C6F9654C0D2ED16AF27738`\r\n5.2.0 - 5.5.0|`CN=DigiCert SHA2 Assured ID Code Signing CA, OU=www.digicert.com, O=DigiCert Inc, C=US`|`C7B0582906E5205B8399D92991694A614D0C0B22`\r\n4.10.0 - 5.1.1|`CN=DigiCert SHA2 Assured ID Code Signing CA, OU=www.digicert.com, O=DigiCert Inc, C=US`|`7B9157664392D633EDA2C0248605C1C868EBDE43`\r\n4.4.3 - 4.9.0|`CN=DigiCert SHA2 Assured ID Code Signing CA, OU=www.digicert.com, O=DigiCert Inc, C=US`|`CC1168BAFCDA3B1A5E532DA87E80A4DD69BCAEB1`\r\n3.0.3 - 4.4.2|No Certificate Found|No Certificate Found\r\n3.4.0|`CN=Microsoft Windows Production PCA 2011, O=Microsoft Corporation, L=Redmond, S=Washington, C=US`|`71F53A26BB1625E466727183409A30D03D7923DF`\r\n\r\nIn all cases, except for version 3.4.0 that was signed directly by Microsoft, the Authenticode issuer for certificate is `CN=Jakub Jareš, O=Jakub Jareš, L=Praha, C=CZ`.\r\n\r\nTo successfully update the module when certificate changed, you need to provide `-SkipPublisherCheck` to the `Install-Module` command.\r\n\r\n## Features\r\n\r\n### Test runner\r\n\r\nPester runs your tests and prints a nicely formatted output to the screen.\r\n\r\n![test run output](images/readme/output.PNG)\r\n\r\nCommand line output is not the only output option, Pester also integrates with Visual Studio Code, Visual Studio, and any tool that can consume nUnit XML output.\r\n\r\n### Assertions\r\n\r\nPester comes with a suite of assertions that cover a lot of common use cases. Pester assertions range from very versatile, like `Should -Be`, to specialized like `Should -Exists`. Here is how you ensure that a file exists:\r\n\r\n```powershell\r\nDescribe 'Notepad' {\r\n    It 'Exists in Windows folder' {\r\n        'C:\\Windows\\notepad.exe' | Should -Exist\r\n    }\r\n}\r\n```\r\n\r\nLearn more about assertions in [our documentation](https://pester.dev/docs/assertions/should-command).\r\n\r\n### Mocking\r\n\r\nPester has mocking built-in. Using mocks you can easily replace functions with empty implementation to avoid changing the real environment.\r\n\r\n```powershell\r\nfunction Remove-Cache {\r\n    Remove-Item \"$env:TEMP\\cache.txt\"\r\n}\r\n\r\nDescribe 'Remove-Cache' {\r\n    It 'Removes cached results from temp\\cache.text' {\r\n        Mock -CommandName Remove-Item -MockWith {}\r\n\r\n        Remove-Cache\r\n\r\n        Should -Invoke -CommandName Remove-Item -Times 1 -Exactly\r\n    }\r\n}\r\n```\r\n\r\nLearn more [about Mocking here](https://pester.dev/docs/usage/mocking).\r\n\r\n### Code coverage\r\n\r\nPester can measure how much of your code is covered by tests and export it to JaCoCo format that is easily understood by build servers.\r\n\r\n![JaCoCo code coverage report](images/readme/jacoco.PNG)\r\n\r\nLearn more about [code coverage here](https://pester.dev/docs/usage/code-coverage).\r\n\r\n### Build server integration\r\n\r\nPester integrates nicely with TFS, AppVeyor, TeamCity, Jenkins and other CI servers.\r\n\r\nTesting your scripts, and all pull requests on AppVeyor is extremely simple. Just commit this `appveyor.yml` file to your repository, and select your repository on the AppVeyor website:\r\n\r\n```yml\r\nversion: 1.0.{build}\r\nimage:\r\n  - Visual Studio 2017\r\n  - Ubuntu\r\ninstall:\r\n  - ps: Install-Module Pester -Force -Scope CurrentUser\r\nbuild: off\r\ntest_script:\r\n  - ps: Invoke-Pester -EnableExit\r\n```\r\n\r\nSee it [in action here!](https://ci.appveyor.com/project/nohwnd/planets)\r\nIf you do not need to test your scripts against PowerShell Core, just simply remove the entire line mentioning Ubuntu.\r\n\r\nPester itself is built on AzureDevOps, and distributed mainly via PowerShell gallery.\r\n\r\n[![Build Status](https://nohwnd.visualstudio.com/Pester/_apis/build/status/Pester%20PR?branchName=main)](https://nohwnd.visualstudio.com/Pester/_build/latest?definitionId=6\u0026branchName=main) [![latest version](https://img.shields.io/powershellgallery/v/Pester.svg?label=latest+version)](https://www.powershellgallery.com/packages/Pester) [![downloads](https://img.shields.io/powershellgallery/dt/Pester.svg?label=downloads)](https://www.powershellgallery.com/packages/Pester)\r\n\r\n## Further reading\r\n\r\nDo you like what you see? Learn how to use Pester with our [quick start guide](https://pester.dev/docs/quick-start).\r\n\r\n## Got questions?\r\n\r\nGot questions or you just want to get in touch? Use our issues page or one of these channels:\r\n\r\n[![Pester Twitter](images/readme/twitter-64.PNG)](https://twitter.com/PSPester) [![Pester on StackOverflow](images/readme/stack-overflow-64.PNG)](https://stackoverflow.com/questions/tagged/pester) [![Testing channel on Powershell Slack](images/readme/slack-64.PNG)](https://powershell.slack.com/messages/C03QKTUCS) [![Testing channel on Powershell Discord](images/readme/discord-64.PNG)](https://discord.gg/powershell) or try github discussions \u003ca href=\"https://github.com/pester/Pester/discussions\"\u003e\u003cimg src=\"https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png\" alt=\"GitHub discussions\" height=\"64\"\u003e\u003c/a\u003e.\r\n\r\n## Sponsored by\r\n\r\nPester is sponsored by [Octopus Deploy](https://octopus.com).\r\n\r\n\u003ca href=\"https://octopus.com\"\u003e\u003cimg src=\"https://octopus.com/images/company/OctopusDeploy-logo-RGB.svg\" alt=\"Octopus deploy\"  height=\"150\"\u003e\u003c/a\u003e\r\n\r\nAs well as all the great folks on [OpenCollective](https://opencollective.com/pester) and [GitHub](https://github.com/users/nohwnd/sponsorship#sponsors).\r\n\r\n## Contributors\r\n\r\n### Code Contributors\r\n\r\nThis project exists thanks to all the people who contribute. [Contribute code](CONTRIBUTING.md).\r\n\u003ca href=\"https://github.com/pester/Pester/graphs/contributors\"\u003e\u003cimg src=\"https://opencollective.com/Pester/contributors.svg?width=890\u0026button=false\" /\u003e\u003c/a\u003e\r\n\r\n### Financial Contributors on Open Collective\r\n\r\nBecome a financial contributor and help us sustain our community. [Contribute to Pester Open Collective](https://opencollective.com/Pester/contribute).\r\n\r\n#### Individuals\r\n\r\n\u003ca href=\"https://opencollective.com/Pester\"\u003e\u003cimg src=\"https://opencollective.com/Pester/individuals.svg?width=890\"\u003e\u003c/a\u003e\r\n\r\n#### Organizations\r\n\r\nSupport this project with your organization. Your logo will show up here with a link to your website. [Contribute](https://opencollective.com/Pester/contribute)\r\n\r\n\u003ca href=\"https://opencollective.com/Pester/organization/0/website\"\u003e\u003cimg src=\"https://opencollective.com/Pester/organization/0/avatar.svg\"\u003e\u003c/a\u003e\r\n\u003ca href=\"https://opencollective.com/Pester/organization/1/website\"\u003e\u003cimg src=\"https://opencollective.com/Pester/organization/1/avatar.svg\"\u003e\u003c/a\u003e\r\n\u003ca href=\"https://opencollective.com/Pester/organization/2/website\"\u003e\u003cimg src=\"https://opencollective.com/Pester/organization/2/avatar.svg\"\u003e\u003c/a\u003e\r\n\u003ca href=\"https://opencollective.com/Pester/organization/3/website\"\u003e\u003cimg src=\"https://opencollective.com/Pester/organization/3/avatar.svg\"\u003e\u003c/a\u003e\r\n\u003ca href=\"https://opencollective.com/Pester/organization/4/website\"\u003e\u003cimg src=\"https://opencollective.com/Pester/organization/4/avatar.svg\"\u003e\u003c/a\u003e\r\n\u003ca href=\"https://opencollective.com/Pester/organization/5/website\"\u003e\u003cimg src=\"https://opencollective.com/Pester/organization/5/avatar.svg\"\u003e\u003c/a\u003e\r\n\u003ca href=\"https://opencollective.com/Pester/organization/6/website\"\u003e\u003cimg src=\"https://opencollective.com/Pester/organization/6/avatar.svg\"\u003e\u003c/a\u003e\r\n\u003ca href=\"https://opencollective.com/Pester/organization/7/website\"\u003e\u003cimg src=\"https://opencollective.com/Pester/organization/7/avatar.svg\"\u003e\u003c/a\u003e\r\n\u003ca href=\"https://opencollective.com/Pester/organization/8/website\"\u003e\u003cimg src=\"https://opencollective.com/Pester/organization/8/avatar.svg\"\u003e\u003c/a\u003e\r\n\u003ca href=\"https://opencollective.com/Pester/organization/9/website\"\u003e\u003cimg src=\"https://opencollective.com/Pester/organization/9/avatar.svg\"\u003e\u003c/a\u003e\r\n","funding_links":["https://github.com/sponsors/nohwnd","https://github.com/sponsors/fflaten","https://opencollective.com/pester","https://opencollective.com/Pester/contribute","https://opencollective.com/Pester","https://opencollective.com/Pester/organization/0/website","https://opencollective.com/Pester/organization/1/website","https://opencollective.com/Pester/organization/2/website","https://opencollective.com/Pester/organization/3/website","https://opencollective.com/Pester/organization/4/website","https://opencollective.com/Pester/organization/5/website","https://opencollective.com/Pester/organization/6/website","https://opencollective.com/Pester/organization/7/website","https://opencollective.com/Pester/organization/8/website","https://opencollective.com/Pester/organization/9/website"],"categories":["PowerShell","Web development tools","Testing"],"sub_categories":["Chess :chess_pawn:"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpester%2FPester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpester%2FPester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpester%2FPester/lists"}