How to ignore parts of a .dump (handling expected differences) #527
-
As a user of the SnapshotTesting library, I'd like to be able to ignore parts of a In my specific use case, the data structure is not entirely under my control and contains generated UUIDs. I guess other use cases might include data like generated time stamps, so I think being able to regex-replace expected differences would be a good way to go. Is there a way to extend the existing strategy in a way that I can make modifications to the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@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:
Our newer library |
Beta Was this translation helpful? Give feedback.
@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:
Mirror
, which means if you can conform the type toCustomReflectable
you can control the dump's hierarchy and return only the fields you want to preserve.swift-snapshot-testing/Sources/SnapshotTesting/Snapshotting/Any.swift
Lines 66 to 75 in 9e28725