I am brand new to Pester and cannot for the life of me find any documentation on how to test a variable is of a certain type.
describe 'All Pester Tests' {
it 'gets an array of all webs in the site collection' {
## Setup
Connect-PnPOnline -Url "https://domain.sharepoint.com/sites/aSpecificSiteCollectionThatExists" -UseWebLogin;
$allwebs = @();
## Positive
$allwebs.GetType().BaseType | Should -BeOfType "[array]";
## Negative
$allwebs.GetType().BaseType | Should -Not -BeOfType "[string]";
}
}
If I do this test manually, I do see my $allwebs is indeed an array
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Array System.Object
When I run Pester, it fails with
[-] All Pester Tests.gets an array of all webs in the site collection 842ms (842ms|1ms)
Expected the value to have type [array] or any of its subtypes, but got [array] with type [System.RuntimeType, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e].
at $allwebs.GetType().BaseType | Should -BeOfType "[array]";, C:\Users\jxr4902\gitcloud\ICC-myApronBackendPowerShellApps\tests\ICC-664-Content-Authors-Are-Able-to-Create-Links-Remove-this-ability.Tests.ps1:40
at <ScriptBlock>, C:\Users\jxr4902\gitcloud\ICC-myApronBackendPowerShellApps\tests\ICC-664-Content-Authors-Are-Able-to-Create-Links-Remove-this-ability.Tests.ps1:40
What is the best way to test a variable for a base type?