fix: resolve test runner scoping issue

see https://github.com/pester/Pester/issues/2386
This commit is contained in:
Rodweil, Theodor 2023-08-06 23:00:48 +02:00
parent 76ea9527b1
commit 956186c654
No known key found for this signature in database
GPG key ID: F8BC1B0EB1F9CCF5
7 changed files with 8 additions and 21 deletions

View file

@ -2,7 +2,7 @@
$ErrorActionPreference = "Stop"
BeforeAll {
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') -Force
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1')
}

View file

@ -2,7 +2,7 @@
$ErrorActionPreference = "Stop"
BeforeAll {
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') -Force
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1')
}

View file

@ -3,7 +3,7 @@ $ErrorActionPreference = "Stop"
BeforeAll {
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') -Force
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1')
}

View file

@ -2,7 +2,7 @@
$ErrorActionPreference = "Stop"
BeforeAll {
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') -Force
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1')
}

View file

@ -2,7 +2,7 @@
$ErrorActionPreference = "Stop"
BeforeAll {
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') -Force
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1')
$mockHost = 'confluence.contoso.com'

View file

@ -2,7 +2,7 @@
$ErrorActionPreference = "Stop"
BeforeAll {
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') -Force
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1')
}
Describe 'Get-StringHash' `

View file

@ -104,20 +104,7 @@ You can execute the following from within a PowerShell session.
``PS> Invoke-Pester PSConfluencePublisher/*.Tests.ps1 -Show 'All'``
However the test suite still requires optimization towards execution, as Pester
requires a certain setup for tests of nested modules to work. The `Force` switch
does not work as expected on the `Import-Module` cmdlet (within the `BeforeAll`
script blocks). Therefore it is advised to wrap the `Invoke-Pester` as follows
so that the global scope gets teared down after execution.
or the following, from within a POSIX shell and PowerShell Core being present:
``$ pwsh -c "Invoke-Pester PSConfluencePublisher/*.Tests.ps1 -Show 'All'"``
There currently is an issue with the invocation of the test suites (see
[Pester Issue #2386](https://github.com/pester/Pester/issues/2386)), where
some tests fail, if ran via the wildcard discovery.
Execute the following from within a PowerShell session to temporarily circumvent
this problem:
``$ pwsh -c 'Get-ChildItem PSConfluencePublisher/*.Tests.ps1 | ForEach {pwsh -c Invoke-Pester (Resolve-Path -Relative $_)}'``