timdeschryver / zod-fixture

Creating fixtures based on zod schemas
https://zod-fixture.timdeschryver.dev/
MIT License
121 stars 10 forks source link

Schema Validation #25

Closed THEtheChad closed 1 year ago

THEtheChad commented 1 year ago

Extends vitest asserts to include a helper that will attempt to parse a fixture against the schema that produced it. Why did I do this? This type of test isn't deterministic in nature since most fixtures generate random values. If a test fails, we would not have enough information to reproduce it. This helper ensures that we have a copy of the seed that produced the fixture so that, in the event that we do get an error, we can accurately reproduce it using the seed provided as input to MersenneTwister.

Case in point. This PR is failing because the multipleOf test failed. Notice that the seed is present so we can accurately reproduce this specific failure and retest.

Screenshot 2023-06-24 at 6 04 16 PM
github-actions[bot] commented 1 year ago

:tada: This PR is included in version 2.0.0-beta.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: