{"id":22529457,"url":"https://github.com/test-kitchen/kitchen-pester","last_synced_at":"2025-08-20T12:32:27.202Z","repository":{"id":29838746,"uuid":"33383477","full_name":"test-kitchen/kitchen-pester","owner":"test-kitchen","description":"A Test Kitchen driver to execute Pester as a verifier","archived":false,"fork":false,"pushed_at":"2023-12-15T17:36:47.000Z","size":219,"stargazers_count":28,"open_issues_count":12,"forks_count":17,"subscribers_count":17,"default_branch":"main","last_synced_at":"2024-04-14T01:51:03.581Z","etag":null,"topics":["hacktoberfest","managed-by-terraform","ruby","ruby-gem","test-kitchen","testing"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/test-kitchen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"support/ci/windows_ci.bat","governance":null,"roadmap":null,"authors":null}},"created_at":"2015-04-03T21:24:28.000Z","updated_at":"2022-08-14T01:23:54.000Z","dependencies_parsed_at":"2023-12-17T04:33:45.855Z","dependency_job_id":null,"html_url":"https://github.com/test-kitchen/kitchen-pester","commit_stats":{"total_commits":192,"total_committers":23,"mean_commits":8.347826086956522,"dds":0.671875,"last_synced_commit":"4a87ee5dbddb67c2ffd1052f8e8def5f8eea35e8"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/test-kitchen%2Fkitchen-pester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/test-kitchen%2Fkitchen-pester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/test-kitchen%2Fkitchen-pester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/test-kitchen%2Fkitchen-pester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/test-kitchen","download_url":"https://codeload.github.com/test-kitchen/kitchen-pester/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230033403,"owners_count":18162611,"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":["hacktoberfest","managed-by-terraform","ruby","ruby-gem","test-kitchen","testing"],"created_at":"2024-12-07T07:14:47.383Z","updated_at":"2024-12-19T11:13:21.798Z","avatar_url":"https://github.com/test-kitchen.png","language":"Ruby","readme":"[![Build Status](https://dev.azure.com/test-kitchen/kitchen-pester/_apis/build/status/test-kitchen.kitchen-pester?branchName=main)](https://dev.azure.com/test-kitchen/kitchen-pester/_build/latest?definitionId=4\u0026branchName=main)\n[![Gem Version](https://badge.fury.io/rb/kitchen-pester.svg)](http://badge.fury.io/rb/kitchen-pester)\n\n# Kitchen::Pester\n\nExecute [Pester](https://github.com/pester/Pester) tests, cross platform, right from Test-Kitchen, without having to transit the Busser layer.\n\nFor now, this gem hasn't been tested with Pester v5+.\n\n## Usage\n\nEither\n```\ngem install kitchen-pester\n```\nor include\n```\ngem 'kitchen-pester'\n```\nin your Gemfile.\n\nIn your .kitchen.yml include\n```yaml\nverifier:\n  name: pester\n```\nThis can be a top-level declaration, a per-node declaration, or a per-suite declaration.\n\n## Options\n\n* `restart_winrm` - boolean, default is `false`. (Windows only)\nRestarts the winrm service using a scheduled tasks before proceding.\nThis setting is ignored on non-windows OSes.\n\n* `test_folder` - string, default is `./tests/integration/`.\nAllows you to specify a custom path (the default is ./test/[integration/]) for your integration tests.\nThis can be an absolute path or relative to the root of the folder kitchen is running from on the host machine.\nThis path must exist.\nWhen you specify a folder, it will automatically try to append `/integration` to that path.\nIf it exists, it will use this as the root tests directory.\nIf it doesn't, it will use the `test_folder`.\nIf you have a `helpers` folders under `test_folder` (i.e. `./tests/helpers`), those will be copied to the SUT for every test suite.\n\n* `remove_builtin_powershellget` - bool, default is `true` (v.1.0.0.1)\nRemove the built-in PowerShellGet and PackageManagement modules on Windows (v1.0.0.1), as they will often cause problems and will be superseded by the bootstrapped versions by default.\n\n* `remove_builtin_pester` - bool, default is `true` (v3.4.0)\nRemove the Pester module that is built-in on Windows (v3.4.0), because upgrading to a later version is awkward if this is not first removed (requires both `-SkipPublisherCheck` \u0026 `-Force`, which makes it slow every time you `kitchen verify`).\nRemoving the built-in ensures that the only version in use will be the Pester version specified by the configuration.\n\n* `bootstrap` - map,  default is `{}` (PowershellGet \u0026 Package Management)\nAllows kitchen-pester to download the PowerShellGet and PackageManagement module directly from the Nuget API URL.\nNote that it needs to be able to download the nupkg from `$galleryUrl/package/PowerShellGet`, which may not be available with some private feed implementations.\n\n* `register_repository` - array (of maps), default is `[]`\nAllows you to register PSRepositories to download modules from. Useful when you want to use a private feed.\nThis expects a map for each repository to register, the values will be splatted to `Register-PSRepository` (or `Set-PSRepository` if it already exists).\n  ```yaml\n    register_repository:\n      - Name: MyPrivateNuget\n        SourceLocation: https://mypsrepo.local/api/v2\n        InstallationPolicy: trusted\n        PackageManagementProvider: Nuget\n  ```\n\n* `install_modules` - array (of maps), default is `[]`\nArray of maps, that will be splatted to the Install-Module parameters.\nUseful for installing dependencies from a gallery.\n  ```yaml\n    install_modules:\n      - Name: MyModule\n        Repository: MyPrivateRepo\n        SkipPublisherCheck: true\n  ```\n\n* `copy_folders` - array, default is `[]`\nFolders (relative to the current directory or absolute) to copy to the System Under Test (SUT).\nThe SUT's `$env:PSModulePath` will have the parent folder prepended for the session.\nIf you are testing a PowerShell module you have built as part of your build process, this enables you to copy the module folder directly to the target machine.\n  ```yaml\n  verifier:\n    name: pester\n    copy_folders:\n      - output/MyModule\n    pester_install:\n      MaximumVersion: '4.99.999'\n  ```\n\n* `skip_pester_install` - bool default is `false`\nSkip installing pester and just use what's available on the box, or what you have copied with the `copy_folders` options.\n\n\n* `pester_install` - map, default is\n  ```ruby\n  {\n    SkipPublisherCheck: true,\n    Force: true,\n    ErrorAction: \"Stop\",\n  }\n  ```\nSpecify parameters for installing Pester before running the tests.\nThe map will be splatted to the `Install-Module -Name Pester` command.\nYou can use this to install the module from a private gallery, for instance.\n\n* `pester_configuration` - hash, defaults to\n  ```ruby\n  {\n    run: {\n      path: \"suites/\",\n      PassThru: true,\n    },\n    TestResult: {\n      Enabled: true,\n      OutputPath: \"PesterTestResults.xml\",\n      TestSuiteName: \"\",\n    },\n    Output: {\n      Verbosity: \"Detailed\",\n    }\n  }\n  ```\n\n  This object is converted to a hashtable used to create a PesterConfiguration object in **Pester v5** (`$PesterConfig = New-PesterConfiguration -Hashtable $pester_configuration`), in turn used with invoke pester (`Invoke-Pester -Configuration $PesterConfig`).\n  If some of the following **keys** are missing, the associated defaults below will be used:\n  - **Run.Path** = `$Env:Temp/verifier/suites`\n  - **TestResult.TestSuiteName** = `Pester - $KitchenInstanceName`\n  - **TestResult.OutputPath** = `$Env:Temp/verifier/PesterTestResults.xml`\n\n  If the installed version of Pester is **v4**, and the `pester_configuration` hash is provided, valid parameters for `Invoke-Pester` will be used (and invalid parameter names will be ignored).\n  In the case of Pester v4, and the `pester_configuration` hash does not provide the keys for `Script`,`OutputFile`,`OutputFormat`, `Passthru`, `PesterOption`, the defaults will be:\n  - Script: `$Env:Temp/verifier/suites`\n  - OutPutFile: `$Env:Temp/verifier/PesterTestResults.xml`\n  - OutputFormat: `NUnitXml`\n  - Passthru: `true`\n  - PesterOption: the result of `$(New-PesterOption -TestSuiteName \"Pester - $KitchenInstanceName)`\n\n* `shell` - string, default is `Nil` which makes it call PowerShell on Windows (Windows PowerShell), pwsh on other OSes.\nIt will honour the `sudo` configuration property if set to true on non-windows.\n\n* `sudo` - bool, default is `false`. (non-windows only)\nExecute all PowerShell calls as sudo.\nThis is necessary in certain cases, such as when `pwsh` is installed via `snap` and is only available via `sudo` unless you customise the system's configuration.\n\n* `downloads`- map[string, string], defaults to `{\"./PesterTestResults.xml\" =\u003e \"./testresults}\"`.\nFiles to download from SUT to local system, used to download the pester results localy.\nThe key is the remote file to download, while the value is the destination.\n  * The source can:\n    * Be relative to the verifier folder (by default `$TEMP/verifier`)\n    * Be absolute on the system (e.g. `/var/tmp/file.zip` or `C:\\\\Windows\\\\Temp\\\\file.zip`)\n  * The destination can:\n    * Include `%{instance_name}` to indicate the Test Kitchen instance name\n    * Be a directory (ends in `/` or `\\\\`)\n    * Be relative to the Current Working Directory\n    * Be absolute\n\n  ```yaml\n  downloads:\n      PesterTestResults.xml: \"./output/testResults/\"\n      kitchen_cmd.ps1: \"./output/testResults/\"\n  ```\n\n* `environment` - map[string, string], defaults to `{}`.\nEnvironment variables to set in SUT for your pester tests to access.\n  ```yaml\n  environment:\n      API_KEY: api-key-here\n      PUSH_URI: https://push.example.com\n  ```\n\n---\n\n## Examples\n\n### Default Windows 2019 Install\n\nIf you're testing on a default image of Windows Server 2019, you probably need to replace the builtin Pester module (v3.4.0), and replace the builtin PackageManagement and PowerShellGet to a more recent for the install to work.\n\nAssuming your tests are written for Peter v4, here's a sample configuration:\n```yaml\nverifier:\n  name: pester\n  pester_install:\n    MaximumVersion: '4.99.999'\n  bootstrap: # installs modules from nuget feed by download and unzip.\n    repository_url: \"https://www.powershellgallery.com/api/v2\"\n    modules:\n      - PackageManagement\n      - PowerShellGet\n```\n\n### Default Azure Ubuntu 18.04 Install\n\nAssuming you are using the AzureRM driver and a Ubuntu image, you may need to install pwsh before being able to execute any PowerShell code.\nOne way to achieve this is by using Test-Kitchen's lifecycle hooks to install it using the [snap](https://snapcraft.io/powershell) package management.\n\nThen if your tests are written for Pester v4.x, make sure you specify a maximum version in the install.\nAs pwsh comes with a recent version of PowerShellGet, it is not necessary to bootstrap the PowerShell environment.\nThe `Install-Module` command should work out of the box.\n\n```yaml\ndriver:\n  name: azurerm\n  subscription_id: \u003c%= ENV['AZ_SUBSCRIPTION_ID'] %\u003e # use a custom env variable\n  location: 'westus2'\n  machine_size: 'Standard_D2s_v3'\n\nprovisioner:\n  name: shell # defaults to bash on linux, so the shebang is important!\n  script: 'tests/integration/provisioning.ps1'\n\nverifier:\n  name: pester\n  pester_install:\n    MaximumVersion: '4.99.999'\n\nplatforms:\n  - name: ubuntu-18.04\n    driver:\n      image_urn: Canonical:UbuntuServer:18.04-LTS:latest\n    lifecycle:\n      post_create:\n      - remote: sudo snap install powershell --classic\n\nsuites:\n  - name: default\n```\n\n### Windows 2012 R2 default install\n\nIf your image is a windows 2012 R2, you will be running on PowerShell v4.\nAssuming that's what you want, but you still need Pester v4 instead of the built-in 3.4.0, you will need to remove the built-in version, bootsrap the PowerShellGet version to a more recent one, and finally install Pester to your desired version.\n\n```yaml\nverifier:\n  name: pester\n  pester_install:\n    MaximumVersion: '4.99.999'\n  bootstrap:\n    repository_url: \"https://www.powershellgallery.com/api/v2\"\n    modules:\n      - PackageManagement\n      - PowerShellGet\n```\n\n---\n\n## Contributing\n\n1. [Fork it](https://github.com/test-kitchen/kitchen-pester/fork)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftest-kitchen%2Fkitchen-pester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftest-kitchen%2Fkitchen-pester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftest-kitchen%2Fkitchen-pester/lists"}