Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Felix Becker
    @felixfbecker
    What’s the state of Pester on macOS? Usable?
    Johan Ljunggren
    @johlju
    I think once the Pester version supporting PowerShell 6 is released then it will work - at least for PowerShell code written for 6.x - but for now only “simple stuff” work in my tests
    Felix Becker
    @felixfbecker
    I can’t get the TestDrive to work, is that because of running on macOS or am I just using it wrong?
    Get-PSDrive : Cannot find drive. A drive with the name 'TestDrive' does not exist.
    At /usr/local/microsoft/powershell/6.0.0-beta.9/Modules/Pester/4.0.8/Functions/TestDrive.ps1:36 char:14
    +     $Path = (& $SafeCommands['Get-PSDrive'] -Name TestDrive).Root
    +              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (TestDrive:String) [Get-PSDrive], DriveNotFoundException
        + FullyQualifiedErrorId : GetLocationNoMatchingDrive,Microsoft.PowerShell.Commands.GetPSDriveCommand
    
        [-] Error occurred in Describe block 1.3s
          ParameterBindingValidationException: Cannot bind argument to parameter 'Path' because it is null.
          at Clear-TestDrive, /usr/local/microsoft/powershell/6.0.0-beta.9/Modules/Pester/4.0.8/Functions/TestDrive.ps1: line 37
          at DescribeImpl, /usr/local/microsoft/powershell/6.0.0-beta.9/Modules/Pester/4.0.8/Functions/Describe.ps1: line 175
          at Describe, /usr/local/microsoft/powershell/6.0.0-beta.9/Modules/Pester/4.0.8/Functions/Describe.ps1: line 84
          at <ScriptBlock>, /Users/felix/git/ps-nvmw/nvm.Tests.ps1: line 3
          at <ScriptBlock>, /usr/local/microsoft/powershell/6.0.0-beta.9/Modules/Pester/4.0.8/Pester.psm1: line 802
          at Invoke-Pester<End>, /usr/local/microsoft/powershell/6.0.0-beta.9/Modules/Pester/4.0.8/Pester.psm1: line 817
          at <ScriptBlock>, <No file>: line 1
    appreciate your help!
    Pester looks awesome, can’t believe PowerShell has a BDD-style testing framework better than most non-scripting languages
    Johan Ljunggren
    @johlju
    Not tried that. What does $TestDrive contain once you are inside a Describe-block? Is it a Windows or *nix path?
    Felix Becker
    @felixfbecker
    I don’t even get into the Describe block
    The error is raised inside Pester
    jonkeda
    @jonkeda

    Hi All, I am looking for feedback on a VS extension for Pester.

    It is located here:
    https://marketplace.visualstudio.com/items?itemName=Jonkers.PowershellPesterTestrunner

    The current version has a Test Toolwindow, a Coverage Toolwindow and shows the line hits in misses in the editor.

    Any comments and suggestions are appreciated.
    Jakub Jareš
    @nohwnd
    @felixfbecker figured it out? TestDrive PSDrive is setup when $Pester is setup.
    Felix Becker
    @felixfbecker
    I was able to run the tests with pester/Pester#925
    Jakub Jareš
    @nohwnd
    @jonkeda looks promising, will try later :)
    @felixfbecker thought so, saw your comment before, but just wanted to confirm with you :)
    Felix Becker
    @felixfbecker
    Didn’t actually end up using TestDrive though. Just got rid of the error
    currently trying to get codecov working
    Felix Becker
    @felixfbecker
    got it
    Jakub Jareš
    @nohwnd
    gr8
    Alex
    @suprak
    Is it possible to mock the call operator &?
    alx9r
    @alx9r
    I’m not sure. I never have. But I have mocked commands called by the call operator.
    Jowj
    @jowj
    Hello! I'm sort of confused about a problem i'm running into.
    Basically, I'm getting odd behavior when I'm trying to assert that an array is either Empty/Null or NOT empty/null
    https://pastebin.com/wTAt3rCq
    as an example, see that code.
    test-PesterPipelineIssue /Users/me/testingDir/testPester.txt | Should beNullOrEmpty
    if you change that line to "should not beNullOrEmpty"` you'll see the behavior change, which i really don't understand.
    (also, sorry if I'm asking in the wrong place. Please let me know if I should move my question to a different location!)
    Jowj
    @jowj
    aaaand nevermind. I nuked my install of psc and pester and resintalled and now I'm getting different behavior
    Disregard!
    itadder
    @itadder
    heya
    PRASOON KARUNAN V
    @kvprasoon
    Hi Folks,
    Pester gives code coverage for lines, do we have a way to get the same for functions ?
    Jakub Jareš
    @nohwnd
    @kvprasoon No, I don't think there is an option for that.
    PRASOON KARUNAN V
    @kvprasoon
    $Thanks @nohwnd
    bartsaintgermain
    @bartsaintgermain
    hello, anybody used the BeforeEachScenario -Tags statement as described in https://kevinmarquette.github.io/2017-04-30-Powershell-Gherkin-advanced-features/#beforeeachscenario. I get the following error: "The expression after '&' in a pipeline element produced an object that was not valid."
    routhrirajan
    @routhrirajan
    Hello, anybody mocked get-environment variable function either user or machine
    routhrirajan
    @routhrirajan
    I have a function to get environment variable, where I have used Get-EnvironmentVariable function to get the value. While writing pester test, I want to mock [System.Environment]::Get-EnvironmentVariable('XXXX', 'User') inorder to test empty scenario and with value scenrio. Can anyone help on this
    Johan Ljunggren
    @johlju
    @routhrirajan Don't think it is possible to mock that, easiest it to make a wrapper (powershell function) for the method [System.Environment]::GetEnvironmentVariable() and mock that. Another way might be to make a stub class and load with Add-Type, but not sure it works in this case since the type is already loaded.
    routhrirajan
    @routhrirajan
    Thanks @johlju I will try with the suggested options. Let you know if it helps
    Chris Forbes
    @kitforbes
    Hi everyone. How do I test a module that has RequiredModules in the manifest. if the dependent modules are not installed, the tests will fail.
    Chris Forbes
    @kitforbes
    Or this may be due to fully qualified function names, I'm not sure.
    Sotiris Nanopoulos
    @davinci26
    Hey @nohwnd I want to take a stab at this pester/Pester#301 . Is it ok? Is there anyone working on something conflicting with this?
    Rushikesh Vyas
    @ruvyas

    Hey guys I am trying to use Pester (4.8.1) for our azure devops pipeline CI build. I have a "publish test" task and
    this is what I am doing right now
    Invoke-Pester -Script $testFilePath -OutputFile $outputFilePath -OutputFormat 'NUnitXML' -CodeCoverage $psFiles -CodeCoverageOutputFile $codeCoverageOutputFIlePath -EnableExit

    My questions is: Is there a way I can put the result in a variable using passthru and and still save all the outputs in the specified files? I want the task to fail if any tests fail but I also have following tasks that shows test result and I want to see which tests failed. With -EnableExit fail it fails the testing task but it skips publishing test result task too

    Heber Alejandro
    @hebers23_twitter
    Hello everyone! how can I send parameters for each test case in a suite? currently I had just one test case to call and I do it like this Invoke-Pester -Script @{Path = 'C:\Turing\Test\Frida-launcher.ps1'; Parameters = @{frida_process_id = '807028544'; frida_user = 'heber.solis@softtek.com'; frida_psw = 'password'}} -OutputFile "frida-results.xml" -OutputFormat "NUnitXML" but I don't know how to do it for every test case in the suite :(. Thanks for any help :)
    radugrecu
    @radugrecu
    is there a way to escape special characters in gherkin step names?
    i found that trying to use parenthesis or square brackets causes it to stop matching the names of the steps in the features to the names of the actual steps
    I tried escaping these with backslash and and the backtick but still can't get it to work
    Carl in 't Veld
    @cveld
    is there a way to define functions in the scope of a unit test that can be called from a MockWith code block?
    @kitforbes I have a related requirement. I have a custom module that is requiring AzureAD and AD to be imported. But obviously these are very large and I want to leave them out. I just mock all the Azure calls. Currently the only way I manage this is to exclude the required modules from the custom module's manifest psd1 file
    Andy AO
    @Andy-AO
    hello everyone
    I don't feel very active here. There are only 69 members.
    Michael Ablassmeier
    @abbbi
    How is it possible to use Variables for Describe and It blocks in V5? It is not necessarily the -TestCases parameter that helps me out. Im testing various command line tools, each test tool goes into its own file (command.Tests.ps1) so it would be neat to use the "command" as variable from the filename in the it and Describe copes (Descript "test ${command}" ..)
    Using BeforeAll with $global:command="foo" is problematic because if pester is called with -Path on a directory with multiple tests. the global variable overrides during execution all other files too,.. i had weird behavior.