tests/KlippyCLI.Tests.ps1
|
#Requires -Modules Pester <# .SYNOPSIS Main test entry point for KlippyCLI module. .DESCRIPTION Loads the module and runs all Pester tests. Unit tests run by default; integration tests require KLIPPY_TEST_PRINTER environment variable. .EXAMPLE Invoke-Pester ./tests/KlippyCLI.Tests.ps1 Runs all unit tests. .EXAMPLE $env:KLIPPY_TEST_PRINTER = "voronv2" Invoke-Pester ./tests/KlippyCLI.Tests.ps1 -Tag Integration Runs integration tests against a real printer. #> BeforeAll { # Import the module from the project root $modulePath = Split-Path -Parent $PSScriptRoot Import-Module "$modulePath/KlippyCLI.psd1" -Force # Helper function to check if integration tests should run function Test-IntegrationTestsEnabled { $null -ne $env:KLIPPY_TEST_PRINTER -and $env:KLIPPY_TEST_PRINTER -ne '' } } Describe "KlippyCLI Module" { It "Should import without errors" { $module = Get-Module -Name KlippyCLI $module | Should -Not -BeNullOrEmpty } It "Should export the expected number of functions" { $commands = Get-Command -Module KlippyCLI $commands.Count | Should -BeGreaterOrEqual 39 } It "Should have a valid module manifest" { $manifestPath = Join-Path (Split-Path -Parent $PSScriptRoot) "KlippyCLI.psd1" { Test-ModuleManifest -Path $manifestPath } | Should -Not -Throw } } |