docs(assert): warn that a data provider shares one snapshot - #1186
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 Background
Related #1185
An unnamed snapshot is named after the test function, and a
@data_providerruns 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 snapshotthough nothing about them is wrong.
💡 Changes
assert_match_named_snapshot "$1"as the way to get one file per valueTried and reverted
A hint in the failure message. The renderer has no signal for "this test ran
with provider arguments" —
_BASHUNIT_CURRENT_TEST_INTERPOLATED_NAMElookedlike 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.