Skip to content

docs(assert): warn that a data provider shares one snapshot - #1186

Merged
Chemaclass merged 1 commit into
mainfrom
docs/1185-snapshot-data-provider
Aug 13, 2026
Merged

docs(assert): warn that a data provider shares one snapshot#1186
Chemaclass merged 1 commit into
mainfrom
docs/1185-snapshot-data-provider

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #1185

An unnamed snapshot is named after the test function, and a @data_provider
runs that function once per value — so every value compares against the same
file. The first creates it; the rest fail with Expected to match the snapshot
though nothing about them is wrong.

💡 Changes

  • Document the interaction, with assert_match_named_snapshot "$1" as the way to get one file per value
  • Acceptance test pinning the current behaviour (one file, second value fails)

Tried and reverted

A hint in the failure message. The renderer has no signal for "this test ran
with provider arguments" — _BASHUNIT_CURRENT_TEST_INTERPOLATED_NAME looked
like one but only fires for ::N::-style titles, so the hint never appeared.
Exposing such a signal, or giving each value its own snapshot file (which would
orphan every snapshot on disk), are design changes for a maintainer rather than
message fixes.

An unnamed snapshot is named after the test function, and a @data_provider runs
that function once per value, so every value compares against the same file.
The first value creates it and the rest fail with 'Expected to match the
snapshot' though nothing about them is wrong -- accurate about the symptom,
silent about the cause.

Documented, with assert_match_named_snapshot "$1" as the way to get one file
per value, plus an acceptance test pinning the behaviour.

A hint in the failure message was tried and reverted: the renderer has no
signal for 'this test ran with provider arguments'.
_BASHUNIT_CURRENT_TEST_INTERPOLATED_NAME looked like one but is only set for
::N::-style titles, so it never fired. Exposing such a signal, or giving each
value its own file (which would orphan every snapshot on disk), are design
changes rather than message fixes.

Closes #1185
@Chemaclass Chemaclass added the documentation Improvements or additions to documentation label Aug 13, 2026
@Chemaclass Chemaclass self-assigned this Aug 13, 2026
@Chemaclass
Chemaclass merged commit 2665712 into main Aug 13, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the docs/1185-snapshot-data-provider branch August 13, 2026 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant