pointfreeco / swift-snapshot-testing

📸 Delightful Swift snapshot testing.

Home Page:https://www.pointfree.co/episodes/ep41-a-tour-of-snapshot-testing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Snapshots tests fail when Json returns in different order,

jambudi opened this issue · comments

How do we resolve the problem when JSON returns in different orders all the time?

Screenshot 2023-11-08 at 4 07 38 PM

Hi @jambudi, the .curl snapshot strategy does not have any awareness of JSON bodies vs HTTP form bodies vs any other kind of body. All it sees is raw data that is encoded to a string.

As such there is nothing the strategy can do to stabilize the data format. Instead, the code producing the JSON string (somewhere in your code) should be responsible for outputting sorted JSON during tests.

As this is not an issue with the library I am going to convert this to a discussion.