Tests/Get-YcRequiredModules.tests.ps1
# Assuming your module is named 'YourModule' and located appropriately Import-Module -Name 'C:\Temp\Yamautomate.Core\Yamautomate.Core.psm1' Describe 'Get-YcRequiredModules' { It 'Checks if the Module is installed' { $moduleName = "SomeModule" Get-Module -ListAvailable -Name $moduleName } It 'If the module is not installed, it displays a message' { $message = "The required module '$moduleName' is not installed. Please install it." Write-Host $message -ForegroundColor Yellow } It 'If the module is installed but not imported, it tries to import it' { if (-not $moduleImported) { $moduleNamePester = "Pester" Import-Module -Name $moduleNamePester } } It 'Displays an Error Message if the module could not be imported' { $moduleName = "SomeModuleThatDoesNotExist" Import-Module -Name $moduleName Write-Error "Could not import module '$moduleName' due to error: $_" } } |