Giter Site home page Giter Site logo

Comments (3)

artbear avatar artbear commented on May 17, 2024

Add:
Text of my script

''''
Set-StrictMode -version 2.0

Describe "Test Set-StrictMode" {

It "Test it" {
    $true | Should Be $true
}

}
''''
Run "invoke-pester myScript.tests.ps1"
and :
Describing Test Set-StrictMode
The variable '$PesterException' cannot be retrieved because it has not been set.
At C:\Users\aayuhanov\Documents\WindowsPowerShell\Modules\Pester\Functions\It.ps1:89 char:60

  • $pester.testResult = Get-PesterResult $pester.ThisTest $PesterException
    
  •                                                        ~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (PesterException:String) [], RuntimeException
    • FullyQualifiedErrorId : VariableIsUndefined

Property 'testResult' cannot be found on this object. Make sure that it exists.
At C:\Users\aayuhanov\Documents\WindowsPowerShell\Modules\Pester\Functions\It.ps1:90 char:5

  • $pester.results.CurrentDescribe.Tests += $pester.testResult
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
    • FullyQualifiedErrorId : PropertyNotFoundStrict

Property 'testResult' cannot be found on this object. Make sure that it exists.
At C:\Users\aayuhanov\Documents\WindowsPowerShell\Modules\Pester\Functions\It.ps1:108 char:8

  • if($pester.testResult.success) {
    
  •    ~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
    • FullyQualifiedErrorId : PropertyNotFoundStrict

Tests completed in 0ms
Passed: 1 Failed: 0

from pester.

scottmuc avatar scottmuc commented on May 17, 2024

PowerShell 2.0 and 3.0 compatibility is sort of in an unknown state right now :-(

I'm currently getting a Windows VM sorted out so I can take a look at this. Thanks for the sample code and output, that'll help in figuring this out.

from pester.

cheretbe avatar cheretbe commented on May 17, 2024

I'm also having this problem with Set-StrictMode.
Initially I was using PS 2.0 and hit this page with Google. I need my scripts to be PS 2.0 compatible, but it's no problem for me to use PS 4.0 for testing.
Unfortunately it doesn't work on PS 4.0 either.
With this test code, offered by artbear:

Set-StrictMode -version "latest"
Describe "Test Set-StrictMode" {
  It "Test it" {
    $true | Should Be $true
  }
}

I get the following output:

Executing all tests in C:\temp
Describing Test Set-StrictMode
The variable '$PesterException' cannot be retrieved because it has not been set.
At C:\Temp\pester\Functions\It.ps1:78 char:67
+     $Result = Get-PesterResult -Test $Test -Time $time -Exception $PesterExcepti ...
+                                                                   ~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (PesterException:String) [], RuntimeException
    + FullyQualifiedErrorId : VariableIsUndefined

The variable '$Result' cannot be retrieved because it has not been set.
At C:\Temp\pester\Functions\It.ps1:79 char:27
+     $Pester.AddTestResult($Result.name, $Result.Success, $result.time, $result.f ...
+                           ~~~~~~~
    + CategoryInfo          : InvalidOperation: (Result:String) [], RuntimeException
    + FullyQualifiedErrorId : VariableIsUndefined

Index was outside the bounds of the array.
At C:\Temp\pester\Functions\It.ps1:80 char:5
+     $Pester.testresult[-1] | Write-PesterResult
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], IndexOutOfRangeException
    + FullyQualifiedErrorId : System.IndexOutOfRangeException

Tests completed in 0ms
Passed: 0 Failed: 0

PowerShell version is 4.0, Pester version is 2.0.4 (March 9, 2014)

from pester.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.