pester Questions

1

PS C:\Users\User\ps-modules> more .\MyStrings.Tests.ps1 function slist { "1", "2", "3" } Describe 'StringTests' { It 'literal -join' { "1", "2&qu...
Dumuzi asked 16/2, 2023 at 3:58

3

Solved

I am writing unit tests for my Powershell Modules, with a file for each module, and Describe blocks for each function. Context blocks organize the tests along the behavior I am trying to test for w...
Educate asked 9/7, 2019 at 20:59

2

Solved

I'm trying to do a simple parallel operation in Powershell. I am using PoshRSJobs for multithreading, though I have also tried Invoke-Parallel with the same issue. I need to call a couple of my o...
Stoeber asked 20/12, 2017 at 20:34

2

Is there any simple approach on how to mock a Rest API Calls in Pester. Here is my code, I just need to mock those Rest API Calls in Pester and test them, could someone help me here. Describe 'Test...
Ochoa asked 25/7, 2021 at 23:27

2

Solved

The Invoke-Pester command makes it possible to invoke a single test script with explicit parameters using the -Script parameter. But what if I want to pass the same parameters to all of the test sc...
Omor asked 25/10, 2019 at 15:9

1

By default, the output in the pipeline is hidden,But sometimes I really want to know the output at that time. Of course, I knew I could add additional commands, such as write-host or out-default. B...
Sodomite asked 29/12, 2020 at 10:11

2

Solved

Problem When a Hashtable is used as input for Should, Pester outputs only the typename instead of the content: Describe 'test' { It 'test case' { $ht = @{ foo = 21; bar = 42 } $ht | Should -BeNu...
Teenateenage asked 6/1, 2021 at 19:38

1

Solved

I'm trying to create a wrapper (proxy) for Pester's Should cmdlet. Possible use cases include transparent logging of test input even in case of success and improve the way Pester logs objects of ce...
Xmas asked 8/1, 2021 at 11:7

1

Solved

Press the shortcut key 'Ctrl+F5' in VSCode to run the Pester test file with the suffix '.tests.ps1'. In 'about_Parsing.Tests.ps1' After you press "Ctrl+F5", the console will directly appe...
Proa asked 23/12, 2020 at 0:43

1

Solved

Question: What would be the best way to import functions to tests that don't reside in the same directory? Example πŸ“ src πŸ“„ Get-Emoji.ps1 πŸ“ test πŸ“„ Get-Emoji.Tests.ps1 Inb4 Pester documentati...
Wellbeloved asked 5/12, 2020 at 18:3

2

Solved

I'm trying to figure out how to have Pester test for parameters that are missing: Find-Waldo.Tests.ps1 $here = Split-Path -Parent $MyInvocation.MyCommand.Path $sut = (Split-Path -Leaf $MyInvocati...
Kurr asked 29/8, 2017 at 9:52

3

Solved

Developing a script in PowerShell, I require to call an external executable file(.exe). currently I am developing this script with a TDD approach, therefore I require to mock the called to this .ex...
Inter asked 20/6, 2016 at 15:55

2

I'm working on some Pester test cases and I'm looking at the CodeCoverage results. In most sets of test cases where we the code contains a try/catch we get 0% coverage on the catch. Here's an examp...
Ileenileitis asked 8/8, 2017 at 16:34

1

Solved

I'm writing tests for a fairly complex script and there's one particular function in the script that will output different series of logging messages to the user. I would like to assert whether a p...
Gustative asked 3/3, 2020 at 15:44

6

Solved

With MS ramming powershell into all new server products, I'm starting to (reluctantly) think I need to take it seriously. Part of "taking it seriously" is TDD. Have you found good methods to unit t...
Shiksa asked 2/6, 2009 at 16:28

2

New to Pester, installed Powershell and Pester on Ubuntu 16.04 per instructions on the Pester Github page https://github.com/pester/Pester. Executed their sample scripts Get-Planet.Tests.ps1 and Ge...
Eakin asked 24/7, 2018 at 23:36

1

Solved

We're trying to assess if Invoke-Command has been called exactly one time. Script.ps1 $job = Invoke-Command -ScriptBlock {'test'} -ComputerName localhost -AsJob $job | Wait-Job Script.Tests.ps1 B...
Crwth asked 16/7, 2018 at 11:18

2

Solved

Pretend I have a function like... function Get-Something { return Get-DogShit } ...in my Pester test script... $var = 1 Mock 'Get-Dogshit' { return $var } it 'should return true' { Get-Some...
Quash asked 5/4, 2018 at 20:30

2

Solved

When I run the following pester test I expect it to catch the expected error but it doesn't. But when I run the test with a different function with a different throw statement it works. Pester Test...
Opsis asked 8/3, 2018 at 19:58

1

Solved

I am having an issue trying to mock a powershell 5 class method, when executing the test, I get the error " CommandNotFoundException: Could not find Command FunctionToMock". I am trying to unit tes...
Lance asked 28/2, 2017 at 16:10

3

Using Pester, I'm mocking an advanced function which takes, amongst other parameters, a switch. How do I create a -parameterFilter for the mock which includes the switch parameter? I've tried: -p...
Seidel asked 11/11, 2013 at 19:3

1

Solved

I need to determine if an array of PSCustomObjects contains an item with its Title property matching a value. I need a Boolean value for use with Pester assertions: $Items -<function> $Name ...
Bass asked 19/6, 2015 at 13:37

2

Solved

I've found a lot of threads around this question here at stackoverflow. They are 2 years old now. So I would like to know if someone is using scottmuc functions to perform a BDD in powershell. It s...
Arthritis asked 17/4, 2011 at 5:20
1

© 2022 - 2024 β€” McMap. All rights reserved.