This questions is really about how to create a Pester test for a custom control using the PowerShell Universal framework. The Pester test in the ud-custom-control-template is clearly written for UD and not PowerShell Universal.
I would like to be able to automatically stand up a temporary Dashboard, run my tests and bin it off.
The Start-PSUServer function is just a wrapper around start process.
function Start-PSUServer {
param(
[Parameter()]
$ExecutablePath = "Universal.Server.exe",
[Parameter()]
$ListenAddress
)
$Command = Get-Command $ExecutablePath -ErrorAction SilentlyContinue
if ($null -eq $Command)
{
throw 'Unable to locate the Universal Server executable. You can use Install-PSUServer to download the latest version. Use the -UpdatePathVariable parameter to add the installation directory the the PATH.'
}
if ($ListenAddress)
{
$Env:Kestrel__Endpoints__HTTP__Url = $ListenAddress
}
Start-Process -FilePath $ExecutablePath
}
You can actually set any setting you’d like via environment variables so you could adjust the path to where PSU looks for the configuration files: https://docs.ironmansoftware.com/config/settings
Where ever you set the repository dir to, you could create your dashboard.ps1 and dashboards.ps1 to use your custom component. I would consider just using the UI to generate all the config files and then include them in your repo so you can just point the temporary PSU instance at them.
If you figure out a good way for testing with Pester, I’d be happy to merge that into the template repository because I think that will help anyone creating a customer component.