Skip to content

Commit 978acce

Browse files
author
MaksimZhukov
committed
Update to Pester 5
1 parent ed56a19 commit 978acce

File tree

2 files changed

+15
-24
lines changed

2 files changed

+15
-24
lines changed

.github/workflows/build-node-packages.yml

+2-8
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,9 @@ jobs:
104104
105105
- name: Run tests
106106
run: |
107-
Install-Module Pester -Force -Scope CurrentUser -RequiredVersion 4.10.1
107+
Install-Module Pester -Force -Scope CurrentUser
108108
Import-Module Pester
109-
$pesterParams = @{
110-
Path="./Node.Tests.ps1";
111-
Parameters=@{
112-
Version="$env:VERSION";
113-
}
114-
}
115-
Invoke-Pester -Script $pesterParams -EnableExit
109+
Invoke-Pester -Script ./Node.Tests.ps1 -EnableExit
116110
working-directory: ./tests
117111

118112
publish_release:

tests/Node.Tests.ps1

+13-16
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
param (
2-
[Version] [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()]
3-
$Version
4-
)
5-
61
Import-Module (Join-Path $PSScriptRoot "../helpers/pester-extensions.psm1")
72

8-
function Get-UseNodeLogs {
9-
# GitHub Windows images don't have `HOME` variable
10-
$homeDir = $env:HOME ?? $env:HOMEDRIVE
11-
$logsFolderPath = Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages" -Resolve
12-
13-
$useNodeLogFile = Get-ChildItem -Path $logsFolderPath | Where-Object {
14-
$logContent = Get-Content $_.Fullname -Raw
15-
return $logContent -match "setup-node@v"
16-
} | Select-Object -First 1
17-
return $useNodeLogFile.Fullname
3+
BeforeAll {
4+
function Get-UseNodeLogs {
5+
# GitHub Windows images don't have `HOME` variable
6+
$homeDir = $env:HOME ?? $env:HOMEDRIVE
7+
$logsFolderPath = Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages" -Resolve
8+
9+
$useNodeLogFile = Get-ChildItem -Path $logsFolderPath | Where-Object {
10+
$logContent = Get-Content $_.Fullname -Raw
11+
return $logContent -match "setup-node@v"
12+
} | Select-Object -First 1
13+
return $useNodeLogFile.Fullname
14+
}
1815
}
1916

2017
Describe "Node.js" {
@@ -24,7 +21,7 @@ Describe "Node.js" {
2421

2522
It "version is correct" {
2623
$versionOutput = Invoke-Expression "node --version"
27-
$versionOutput | Should -Match $Version
24+
$versionOutput | Should -Match $env:VERSION
2825
}
2926

3027
It "is used from tool-cache" {

0 commit comments

Comments
 (0)