Skip to content

Conversation

calda
Copy link
Contributor

@calda calda commented Dec 10, 2021

I'm setting up snapshot testing for the Lottie project (airbnb/lottie-ios#1432). We're currently running snapshot tests using this library via the command line in CI.

Our tests are setup dynamically, so all run in the same testLottieSnapshots method but have a different name (the name of the file being snapshot).

Currently, the assertion messages only include the name of the test case. This makes it challenging to know which individual snapshot is failing:

    ✖ testLottieSnapshots, failed - Snapshot does not match reference.
    ✖ testLottieSnapshots, failed - Snapshot does not match reference.
    ✖ testLottieSnapshots, failed - Snapshot does not match reference.
    ✖ testLottieSnapshots, failed - Snapshot does not match reference.
    ✖ testLottieSnapshots, failed - Snapshot does not match reference.
    ✖ testLottieSnapshots, failed - Snapshot does not match reference.
    ✖ testLottieSnapshots, failed - Snapshot does not match reference.
    ✖ testLottieSnapshots, failed - Snapshot does not match reference.
    ✖ testLottieSnapshots, failed - Snapshot does not match reference.

This PR updates the assertion failure message to include the snapshot name, if given. With this change, it's much easier to tell which individual snapshot is failing:

    ✖ testLottieSnapshots, failed - Snapshot "LottieLogo1 (0%)" does not match reference.
    ✖ testLottieSnapshots, failed - Snapshot "LottieLogo1 (50%)" does not match reference.
    ✖ testLottieSnapshots, failed - Snapshot "LottieLogo1 (100%)" does not match reference.
    ✖ testLottieSnapshots, failed - Snapshot "Apostrophe (0%)" does not match reference.
    ✖ testLottieSnapshots, failed - Snapshot "Apostrophe (50%)" does not match reference.
    ✖ testLottieSnapshots, failed - Snapshot "Apostrophe (100%)" does not match reference.
    ✖ testLottieSnapshots, failed - Snapshot "P (0%)" does not match reference.
    ✖ testLottieSnapshots, failed - Snapshot "P (50%)" does not match reference.
    ✖ testLottieSnapshots, failed - Snapshot "P (100%)" does not match reference.

Copy link
Member

@mbrandonw mbrandonw left a comment

Choose a reason for hiding this comment

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

Looks great @calda, thanks for the PR!

@mbrandonw mbrandonw merged commit 0259c2f into pointfreeco:main Dec 13, 2021
niil-qb pushed a commit to quickbit/swift-snapshot-testing that referenced this pull request Feb 23, 2023
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.

2 participants