Closed jamestelfer closed 1 year ago
Base: 87.02% // Head: 87.04% // Increases project coverage by +0.01%
:tada:
Coverage data is based on head (
7496539
) compared to base (0854b36
). Patch coverage: 100.00% of modified lines in pull request are covered.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Snapshots containing maps are unstable because iteration order of a map's keys is not guaranteed. This leads to test instability, where instability increases with the size of the map included in the snapshot.
Stability can be introduced by using the option of the go-spew library that sorts map keys before serialization (the
SortKeys
option). TheSortKeys
option only deals with keys that are native types, or types that implementStringer
orerror
, but this covers a significant proportion of the uses ofmap
.Breaking change: This change turns the
SortKeys
option on for all snapshots, potentially invalidating snapshots that already exist. In reality though, given the instability of maps in snapshots currently, it's unlikely any user of the library will be affected.Further development
There is another option:
SpewKeys
. This extends the function ofSortKeys
to other types by first usinggo-spew
to serialize the type to a string. In my opinion, this is likely to either be (a) something a library user might want to opt into, and (b) a less-likely scenario. For this reason, I've left that option as a potential future development.See also
go-spew
configuration reference.