From 978acceff51ee1dc14cbd623c52a9428effb49d4 Mon Sep 17 00:00:00 2001 From: MaksimZhukov Date: Mon, 24 Aug 2020 20:07:31 +0300 Subject: [PATCH] Update to Pester 5 --- .github/workflows/build-node-packages.yml | 10 ++------- tests/Node.Tests.ps1 | 27 ++++++++++------------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build-node-packages.yml b/.github/workflows/build-node-packages.yml index 471407a..25b1fe0 100644 --- a/.github/workflows/build-node-packages.yml +++ b/.github/workflows/build-node-packages.yml @@ -104,15 +104,9 @@ jobs: - name: Run tests run: | - Install-Module Pester -Force -Scope CurrentUser -RequiredVersion 4.10.1 + Install-Module Pester -Force -Scope CurrentUser Import-Module Pester - $pesterParams = @{ - Path="./Node.Tests.ps1"; - Parameters=@{ - Version="$env:VERSION"; - } - } - Invoke-Pester -Script $pesterParams -EnableExit + Invoke-Pester -Script ./Node.Tests.ps1 -EnableExit working-directory: ./tests publish_release: diff --git a/tests/Node.Tests.ps1 b/tests/Node.Tests.ps1 index aaa91dc..97d671a 100644 --- a/tests/Node.Tests.ps1 +++ b/tests/Node.Tests.ps1 @@ -1,20 +1,17 @@ -param ( - [Version] [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] - $Version -) - Import-Module (Join-Path $PSScriptRoot "../helpers/pester-extensions.psm1") -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 +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 - $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 + $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 + } } Describe "Node.js" { @@ -24,7 +21,7 @@ Describe "Node.js" { It "version is correct" { $versionOutput = Invoke-Expression "node --version" - $versionOutput | Should -Match $Version + $versionOutput | Should -Match $env:VERSION } It "is used from tool-cache" {