diff --git a/tests/Node.Tests.ps1 b/tests/Node.Tests.ps1 index 97d671a..54fca91 100644 --- a/tests/Node.Tests.ps1 +++ b/tests/Node.Tests.ps1 @@ -2,17 +2,22 @@ Import-Module (Join-Path $PSScriptRoot "../helpers/pester-extensions.psm1") BeforeAll { function Get-UseNodeLogs { - # GitHub Windows images don't have `HOME` variable - $homeDir = $env:HOME ?? $env:HOMEDRIVE - $logsFolderPath = Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages" -Resolve + # GitHub Windows images don't have `HOME` variable + $homeDir = $env:HOME ?? $env:HOMEDRIVE + $logsFolderPath = Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages" -Resolve + if (Test-Path -Path $logsFolderPath) { $useNodeLogFile = Get-ChildItem -Path $logsFolderPath | Where-Object { $logContent = Get-Content $_.Fullname -Raw return $logContent -match "setup-node@v" } | Select-Object -First 1 return $useNodeLogFile.Fullname + } else { + Write-Host "Directory '$logsFolderPath' does not exist." + return $null } } +} Describe "Node.js" { It "is available" { @@ -45,4 +50,4 @@ Describe "Node.js" { It "Run simple code" { "node ./simple-test.js" | Should -ReturnZeroExitCode } -} \ No newline at end of file +}