-
-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[V5rc6] Invoke-Pester -CI Various Issues #1527
Comments
I narrowed this down to specifically Configuration.Run.Exit. Setting this to $true causes both issues without -CI specified. |
On a closer look this works as designed. The process will exit with the correct code, and the object is output to the pipeline prior to that. The thing is that in VSCode which is where you are probably trying it, it won't exit the process when calling exit, because of the special things they do to prevent that. So you will not close the process, but you also won't reach the If you run it in a separate process it will run correctly: $r = pwsh -c "import-module /projects/pester/bin/pester.psd1; invoke-pester C:\temp\Get-Emoji.Tests.ps1 -ci -passthru"; $lastexitcode; $r
1
Starting discovery in 1 files.
Discovery finished in 173ms.
[-] Get-Emoji.Gets avocado 48ms (45ms|3ms)
Expected strings to be the same, but they were different.
String lengths are both 2.
Strings differ at index 0.
Expected: '🥑'
But was: '🌵'
at Get-Emoji -Emoji avocado | Should -Be '🥑', C:\temp\Get-Emoji.Tests.ps1:11
at <ScriptBlock>, C:\temp\Get-Emoji.Tests.ps1:11
Tests completed in 890ms
Tests Passed: 1, Failed: 1, Skipped: 0 NotRun: 0
Containers : {[-] C:\temp\Get-Emoji.Tests.ps1}
Result : Failed |
@nohwnd confirmed, I also forgot "exit" will kill the entire process which makes sense the behavior I was hitting. Maybe -CI needs an option to throw a terminating error rather than "Exit" for when running pester in a CI build script such as Invoke-Build or PSake. For now I just do a custom configuration and compare against the failedTests in the result, but for the -CI to have it's intended result, I think this is a worthwhile 5.1 item. |
I agree throwing on failed run is needed, I am working around this in multiple pipelines as well. |
1. General summary of the issue
PassThru doesn't save to variable
Invoke-Pester -PassThru works as expected and can be assigned to a variable
Invoke-Pester -PassThru -CI causes the object to not go to output and cannot be assigned.
LastExitCode doesn't work
The text was updated successfully, but these errors were encountered: