Skip to content

Commit 4ebdcfb

Browse files
committed
fix: 🐛 improve test assertions
* Enhanced test assertions to provide clearer output and ensure all expected files exist.
1 parent 6b5d700 commit 4ebdcfb

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

.github/workflows/test.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@ jobs:
1616
- uses: actions/checkout@v4
1717
- name: Test
1818
shell: pwsh
19-
run: ./build.ps1 -Task Test -Bootstrap
19+
env:
20+
DEBUG: ${{ runner.debug == '1' }}
21+
run: |
22+
if($env:DEBUG -eq 'true' -or $env:DEBUG -eq '1') {
23+
$DebugPreference = 'Continue'
24+
}
25+
./build.ps1 -Task Test -Bootstrap

tests/build.tests.ps1

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Describe 'Build' {
1919
Write-Host "OutputPath: $script:testModuleOutputPath"
2020

2121
# build is PS job so psake doesn't freak out because it's nested
22-
Start-Job -ScriptBlock {
22+
Start-Job -Scriptblock {
2323
Set-Location $using:PSScriptRoot/TestModule
2424
$global:PSBuildCompile = $true
2525
./build.ps1 -Task Build
@@ -71,7 +71,7 @@ Describe 'Build' {
7171
Context 'Dot-sourced module' {
7272
BeforeAll {
7373
# build is PS job so psake doesn't freak out because it's nested
74-
Start-Job -ScriptBlock {
74+
Start-Job -Scriptblock {
7575
Set-Location $using:PSScriptRoot/TestModule
7676
$global:PSBuildCompile = $false
7777
./build.ps1 -Task Build
@@ -87,11 +87,18 @@ Describe 'Build' {
8787
}
8888

8989
It 'Has PSD1 and dot-sourced functions' {
90-
(Get-ChildItem -Path $script:testModuleOutputPath).Count | Should -Be 6
91-
"$script:testModuleOutputPath/TestModule.psd1" | Should -Exist
92-
"$script:testModuleOutputPath/TestModule.psm1" | Should -Exist
93-
"$script:testModuleOutputPath/Public" | Should -Exist
94-
"$script:testModuleOutputPath/Private" | Should -Exist
90+
$items = Get-ChildItem -Path $script:testModuleOutputPath
91+
Write-Debug $items
92+
$items.Count | Should -Be 6
93+
}
94+
95+
It '<_> should exist' -ForEach @(
96+
"$script:testModuleOutputPath/TestModule.psd1"
97+
"$script:testModuleOutputPath/TestModule.psm1"
98+
"$script:testModuleOutputPath/Public"
99+
"$script:testModuleOutputPath/Private"
100+
) {
101+
$_ | Should -Exist
95102
}
96103

97104
It 'Does not contain excluded stuff' {

0 commit comments

Comments
 (0)