Skip to content

Add 'None' tag filter to run or exclude tests without tags#2836

Merged
nohwnd merged 2 commits into
pester:mainfrom
nohwnd:nohwnd-expert-fishstick
Jul 3, 2026
Merged

Add 'None' tag filter to run or exclude tests without tags#2836
nohwnd merged 2 commits into
pester:mainfrom
nohwnd:nohwnd-expert-fishstick

Conversation

@nohwnd

@nohwnd nohwnd commented Jul 3, 2026

Copy link
Copy Markdown
Member

Summary

Adds a reserved None value to the tag filters so you can select tests that have no tags.

  • -TagFilter 'None' / Filter.Tag = 'None' runs only tests with no tag on themselves or on any parent block.
  • -ExcludeTagFilter 'None' / Filter.ExcludeTag = 'None' skips those untagged tests, so only tagged tests run.
  • None is matched case-insensitively and can be combined with real tags, e.g. -TagFilter None, Acceptance.
  • A test/block literally tagged None is still matched by the filter (normal -like path), so nothing silently falls through.

Tags inherit downward in Pester, so an untagged test inside a tagged block is treated as tagged and is not selected by None. The no-tags rule is applied to leaf tests only, so an untagged block never force-includes or force-excludes its tagged children.

Implementation

  • New Test-HasNoEffectiveTag helper in src/Pester.Runtime.ps1 walks the item and its parent blocks up to the root, returning $true only when no tag is found anywhere.
  • Test-ShouldRun include (Filter.Tag) and exclude (Filter.ExcludeTag) sections handle None before the existing -like matching.

Breaking change

None is now a reserved tag-filter value. Previously it matched a literal tag named None; now it means "tests without tags". Documented in the Breaking changes section of docs/6.0.0.md.

Tests

11 new cases in tst/Pester.Rspec.Filtering.ts.ps1 covering include/exclude, inherited tags, nested untagged blocks, no force-include of tagged siblings, literal None tag, case-insensitivity, and combining None with another tag.

  • Filtering: 22/22 pass
  • Runtime: 101/101 pass
  • RSpec: 116/116 pass

Docs (usage/tags, configuration, v5→v6 migration) are handled in a companion PR in pester/docs.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

nohwnd and others added 2 commits July 3, 2026 21:33
`-TagFilter 'None'` (Filter.Tag) now selects tests that have no tag on
themselves or on any parent block, and `-ExcludeTagFilter 'None'`
(Filter.ExcludeTag) skips them so only tagged tests run. 'None' is matched
case-insensitively and can be combined with real tags. A test literally
tagged 'None' is still matched by the filter.

Tags inherit downward, so an untagged test inside a tagged block is treated
as tagged and is not selected by 'None'. The no-tags rule is applied to
leaf tests only, so an untagged block does not force-include or exclude its
tagged children.

This reserves 'None' as a tag-filter value (breaking change); noted in the
6.0.0 release notes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update the Filter.Tag and Filter.ExcludeTag option descriptions in
FilterConfiguration.cs so the config object, Get-Help, and the generated
about_PesterConfiguration help mention that 'None' selects tests without
tags. Regenerated the about_PesterConfiguration help text.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nohwnd nohwnd enabled auto-merge (squash) July 3, 2026 19:50
@nohwnd nohwnd merged commit a91d3c5 into pester:main Jul 3, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant