zod-fast-check icon indicating copy to clipboard operation
zod-fast-check copied to clipboard

ZodFastCheck().outputOf(z.record(z.number(), z.number())) only builds empty records

Open exarkun opened this issue 4 months ago • 1 comments

This test passes:

     it('only builds empty records', () => {
        fc.assert(
          fc.property(
            ZodFastCheck().outputOf(z.record(z.number(), z.number())),
            (xs) => {
              assert(Object.keys(xs).length === 0);
            },
          ),
        );
      });

But it would be great if it failed.

exarkun avatar Aug 13 '25 16:08 exarkun

Changing the zod schema to z.record(z.number()) (i.e., not supplying a schema for the keys) produces the expected behavior - the resulting record may have more than zero properties - so I suppose the issue has to do with how zod records with custom key schemas are handled.

exarkun avatar Aug 13 '25 16:08 exarkun