@traversable/schema
    Preparing search index...
    • Convert a Zod schema into a fast-check arbitrary.

      Configure how fuzzed values will be generated via type options argument.

      Override individual arbitraries via the overrides argument.

      Note: zxTest.fuzz is the only schema-to-generator function that has itself been fuzz tested to ensure that no matter what schema you give it, the data-generator that fuzz returns will always produce valid data.

      The only known exceptions are schemas that make it impossible to generate valid data. For example:

      • z.never
      • z.nonoptional(z.undefined())
      • z.enum([])
      • z.union([])
      • z.intersection(z.number(), z.string())

      See also:

      Type Parameters

      • T

      Parameters

      Returns Arbitrary<T>

      import * as vi from 'vitest'
      import * as fc from 'fast-check' * import { fuzz } from '@traversable/zod-test'

      const Schema = z.record(
      z.string(),
      z.union(
      z.number(),
      z.string(),
      )
      )

      const generator = fuzz(
      Schema,
      { record: { minKeys: 1 }, number: { noDefaultInfinity: true } },
      { string: () => fc.stringMatching(/[\S\s]+[\S]+/) },
      )

      vi.test('fuzz test example', () => {
      fc.assert(
      fc.property(generator, (data) => {
      vi.assert.doesNotThrow(() => Schema.parse(data))
      }),
      { numRuns: 1_000 }
      )
      })