Skip to content

How to ignore parts of a .dump (handling expected differences) #527

Answered by stephencelis
jklingen asked this question in Q&A
Discussion options

You must be logged in to vote

@jklingen I'm going to convert this to a discussion since it's a question and not a bug report.

There are a couple ways to override a portion of a dump:

  1. Under the hood, the dump strategy uses Mirror, which means if you can conform the type to CustomReflectable you can control the dump's hierarchy and return only the fields you want to preserve.
  2. SnapshotTesting also ships with a protocol that allows you to override that portion of the dump with a string:
    /// A type with a customized snapshot dump representation.
    ///
    /// Types that conform to the `AnySnapshotStringConvertib…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jklingen
Comment options

Answer selected by jklingen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #526 on October 19, 2021 14:16.