timdeschryver / zod-fixture

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

`expect` Helper Semantics #38

Closed THEtheChad closed 1 year ago

THEtheChad commented 1 year ago

The test helper toProduce was renamed toReasonablySatisfy as it more clearly describes what the helper is actually doing. This type of test doesn't guarantee that the fixture will actually parse with the zod schema provided, but it does bolster our confidence that we will eventually catch edge cases where it doesn't.

I also removed the value parameter as that can be tested separately using the existing assertions.

const schema = z.null()
const fixture = new Fixture()

// test ability to parse - default 100 iterations
expect( fixture ).toReasonablySatisfy( schema )
// test value
expect( fixture.from(schema) ).toBe( null )

** syntax above assumes refactor but this PR is branched off beta

github-actions[bot] commented 1 year ago

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

The release is available on:

Your semantic-release bot :package::rocket: