Implementing Runner-Specific Node.js Tests (#178)

* Update Node.Tests.ps1

* Update Node.Tests.ps1

* Update Node.Tests.ps1

---------

Co-authored-by: aparnajyothi-y <147696841+aparnajyothi-y@users.noreply.github.com>
This commit is contained in:
gowridurgad 2024-07-09 20:31:27 +05:30 committed by GitHub
parent 3a7a3835dd
commit c8cf9cb4b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,9 @@
Import-Module (Join-Path $PSScriptRoot "../helpers/pester-extensions.psm1")
Describe "Node.js" {
BeforeAll {
function Get-UseNodeLogs {
# GitHub Windows images don't have `HOME` variable
@ -14,7 +18,6 @@ BeforeAll {
}
}
Describe "Node.js" {
It "is available" {
"node --version" | Should -ReturnZeroExitCode
}
@ -35,12 +38,22 @@ Describe "Node.js" {
}
It "cached version is used without downloading" {
if ($env:RUNNER_TYPE -eq "self-hosted") {
# Get the installed version of Node.js
$nodeVersion = Invoke-Expression "node --version"
# Check if Node.js is installed
$nodeVersion | Should -Not -BeNullOrEmpty
# Check if the installed version of Node.js is the expected version
$nodeVersion | Should -Match $env:VERSION
}else {
# Analyze output of previous steps to check if Node.js was consumed from cache or downloaded
$useNodeLogFile = Get-UseNodeLogs
$useNodeLogFile | Should -Exist
$useNodeLogContent = Get-Content $useNodeLogFile -Raw
$useNodeLogContent | Should -Match "Found in cache"
}
}
It "Run simple code" {
"node ./simple-test.js" | Should -ReturnZeroExitCode