Skip to content

🪲 [Fix]: Type-accelerator tests handle modules without enums or classes#120

Merged
Marius Storhaug (MariusStorhaug) merged 4 commits into
mainfrom
fix/pester6-empty-foreach
Jul 8, 2026
Merged

🪲 [Fix]: Type-accelerator tests handle modules without enums or classes#120
Marius Storhaug (MariusStorhaug) merged 4 commits into
mainfrom
fix/pester6-empty-foreach

Conversation

@MariusStorhaug

@MariusStorhaug Marius Storhaug (MariusStorhaug) commented Jul 8, 2026

Copy link
Copy Markdown
Member

Module test runs now handle modules that export only one kind of public type under Pester 6. Type-accelerator checks skip empty enum or class collections instead of failing discovery, so Test-PSModule can validate modules that have classes without enums, enums without classes, or both.

Fixed: Type-accelerator tests handle missing enum or class exports

Modules no longer fail the Test-PSModule module test suite just because one type category is empty. If a module has public classes but no public enums, the enum registration check is skipped and the class registration checks still run. If a module has public enums but no public classes, the class registration check is skipped and the enum registration checks still run.

This resolves the Pester 6 discovery failure caused by empty -ForEach collections while preserving coverage for the exported types that do exist.

Technical Details

  • src/tests/Module/PSModule/PSModule.Tests.ps1 now passes -AllowNullOrEmptyForEach to both type-accelerator It blocks.
  • .github/workflows/Action-Test-outputs.yml now runs the output fixture workflow against both the existing class-only fixture and a new enum-only fixture.
  • tests/outputEnumOnlyTestRepo/outputs/module/PSModuleEnumOnly adds a minimal enum-only module fixture for the missing coverage path.
  • The enum-only fixture cleanup only removes accelerators that still point to the type exported by that fixture, avoiding removal of pre-existing accelerators with the same name.

Pester 6 defaults Run.FailOnNullOrEmptyForEach to true, so the enum/class type-accelerator It blocks fail Discovery for a fixture module that has classes but no enums (or vice versa). Add -AllowNullOrEmptyForEach so an empty collection is skipped instead of failing the container. Fixes the Action-Test-outputs failure on main.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Pester 6 discovery failures in the module test suite by allowing It ... -ForEach blocks to accept empty enumerations, so modules without enums/classes don’t fail the entire container during discovery.

Changes:

  • Add -AllowNullOrEmptyForEach to the enum type-accelerator It block.
  • Add -AllowNullOrEmptyForEach to the class type-accelerator It block.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings July 8, 2026 09:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 8, 2026 09:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 8, 2026 09:43
@MariusStorhaug Marius Storhaug (MariusStorhaug) changed the title 🩹 [Patch]: Allow empty -ForEach in type-accelerator tests (Pester 6 compat) 🪲 [Fix]: Type-accelerator tests handle modules without enums or classes Jul 8, 2026
@MariusStorhaug Marius Storhaug (MariusStorhaug) merged commit 033609e into main Jul 8, 2026
30 checks passed
@MariusStorhaug Marius Storhaug (MariusStorhaug) deleted the fix/pester6-empty-foreach branch July 8, 2026 09:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants