re: "I need to change this code, but it has no test" VIEW POST

FULL DISCUSSION
 

You might want to check out JSON schema if you use snapshots for object validation. Snapshots are usually brittle because they check for equality but can't account for equivalency (is it this string, not a string -- something that can be somewhat mitigated by logic producing a lot of possible snapshots for testing), whereas schema validation can check for structure, type and even patterns/constant equality. Even more: you can generate randomized testing data from a schema at runtime so that your tests are even further decoupled from the actual test data.

 

Thanks for sharing Marc, this could have indeed interesting use-cases.

In the blog post example, I think snapshots are what we want to use though. We don't want to check just the structure, but the actual content of the data.

But I'll keep JSON schema in mind, it could be useful 👍

code of conduct - report abuse