Viscalyx.Assert

1.2.0

Assertions for Pester that can improve your tests.

Minimum PowerShell version

5.1

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Module -Name Viscalyx.Assert

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet More Info

Install-PSResource -Name Viscalyx.Assert

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

Owners

Copyright

Copyright the Viscalyx.Assert contributors. All rights reserved.

Package Details

Author(s)

  • Viscalyx

Tags

Pester Assertion Testing TDD BDD Assert PesterAssertion

Functions

Assert-BlockString Assert-ObjectMethod Assert-ObjectProperty

Dependencies

This module has no dependencies.

Release Notes

## [1.2.0] - 2025-10-04

### Added

- `Assert-ObjectProperty`
 - Added parameter `NoTypeCheck` to opt-in for lenient type checking, allowing
   PowerShell type coercion when comparing values.
- Added private functions:
 - `Get-TypeName` - Gets the full type name of a value as a string, or 'null'
   if the value is null.
 - `New-AssertionError` - Creates a Pester assertion error record with optional
   'because' reasoning to standardize error creation across assertion commands.
 - `Test-ObjectHasMethod` - Tests whether an object has a specified method,
   supporting various object types including PSCustomObjects and .NET objects.
 - `Test-ObjectHasProperty` - Tests whether an object has a specified property,
   supporting hashtables, PSCustomObjects, and .NET objects.
 - `Test-ObjectType` - Tests whether two values have the same type for strict
   type checking in assertion commands.
 - `Test-ValueEquality` - Tests whether two values are equal, supporting both
   scalar values and arrays with structural comparison.

### Changed

- `Assert-ObjectProperty`
 - Added parameter `Each` to opt-in for element-by-element checking when
   passing arrays via pipeline or parameter. Without this parameter, the
   command now checks properties on the array object itself (e.g., `Count`,
   `Length`).
 - Improved error messages to distinguish between type mismatches and value
   mismatches when strict type checking is enabled.
- `Assert-ObjectMethod`
 - Added parameter `Each` to opt-in for element-by-element checking when
   passing arrays via pipeline or parameter. Without this parameter, the
   command now checks methods on the array object itself.
- `Assert-BlockString`
 - Refactored to use the `New-AssertionError` private function for consistent
   error handling across all assertion commands.
- `New-AssertionError`
 - Updated to follow Pester's error message pattern by inserting the `Because`
   clause before `, but` in error messages (e.g., "Expected \<value\>, because
   \<reason\>, but got \<actual\>").
- Localized strings have been reorganized to consolidate common reusable words
 (like "because", "actual", and "expected") into a dedicated "Common localized
 strings" section with a consistent `Common_Word*` naming pattern, reducing
 duplication across command-specific string keys.

FileList

Version History

Version Downloads Last updated
1.2.0 (current version) 5 10/4/2025
1.1.1-previe... 3 10/4/2025
1.1.0 5 10/3/2025
1.1.0-previe... 3 10/3/2025
1.0.0 14 2/4/2025
0.1.1-previe... 4 2/4/2025
0.1.1-previe... 4 2/2/2025
0.1.1-previe... 4 2/2/2025
0.1.1-previe... 67 8/26/2024
0.1.1-previe... 53 8/22/2024
0.1.0-previe... 4 8/20/2024
Show more