vee-validate icon indicating copy to clipboard operation
vee-validate copied to clipboard

🐛 vee-validate/zod: TypeError: 'get' on proxy: property '0' is a read-only and non-configurable data property on the proxy target

Open sschneider-ihre-pvs opened this issue 3 years ago • 2 comments

What happened?

I tried to test the result of a form validation with jest and got the following error

TypeError: 'get' on proxy: property '0' is a read-only and non-configurable data property on the proxy target but the proxy did not return its actual value (expected '#<Object>' but got '#<Object>') at Proxy.map ()

When I try to use jest.useFakeTimers() no test will finish within the timeout range, not even setting it to 20000.

Reproduction steps

A simplified version

const createWrapper = () => render('somecomponent)
it('should prevent input too long', async () => {
      const { getAllByTestId } = createWrapper();
      await flushPromises();

      const dummyText = chance.string({ length: 5, pool: '12345' });

      const field = getAllByTestId('testid') as HTMLInputElement[];
      await userEvent.clear(field[0]);
      await userEvent.type(field[0], dummyText);

      await flushAll();

      expect(field[0]?.value).not.toBe(dummyText);
    });

Version

Vue.js 3.x and vee-validate 4.x

What browsers are you seeing the problem on?

  • [X] Firefox
  • [X] Chrome
  • [X] Safari
  • [X] Microsoft Edge

Relevant log output

at ZodArray.Object.<anonymous>.ZodArray._parse (node_modules/zod/src/types.ts:1196:29)
      at ZodOptional.Object.<anonymous>.ZodOptional._parse (node_modules/zod/src/types.ts:3089:32)
      at ZodNullable.Object.<anonymous>.ZodNullable._parse (node_modules/zod/src/types.ts:3137:32)
      at ZodObject.Object.<anonymous>.ZodObject._parse (node_modules/zod/src/types.ts:1467:29)
      at ZodLazy.Object.<anonymous>.ZodLazy._parse (node_modules/zod/src/types.ts:2629:23)
      at ZodLazy.<anonymous> (node_modules/zod/src/types.ts:212:35)
      at step (node_modules/zod/lib/types.js:59:23)
      at Object.next (node_modules/zod/lib/types.js:40:53)
      at node_modules/zod/lib/types.js:34:71
      at Object.<anonymous>.__awaiter (node_modules/zod/lib/types.js:30:12)
      at ZodLazy.Object.<anonymous>.ZodType.safeParseAsync (node_modules/zod/lib/types.js:209:16)
      at Object.validate (node_modules/@vee-validate/zod/dist/vee-validate-zod.js:39:46)
      at validateYupSchema (node_modules/vee-validate/dist/vee-validate.js:603:12)
      at _validateSchema (node_modules/vee-validate/dist/vee-validate.js:1784:23)
      at node_modules/vee-validate/dist/vee-validate.js:283:30
      at Timeout.task [as _onTimeout] (node_modules/jsdom/lib/jsdom/browser/Window.js:516:19)

Demo link

null

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

sschneider-ihre-pvs avatar Feb 07 '22 14:02 sschneider-ihre-pvs

There isn't enough information for me to debug here, please attach a link to a repo with minimal reproduction of this error. So you would need to create a project with jest test that triggers this error.

logaretm avatar Feb 07 '22 23:02 logaretm

That is pretty much impossible. I don't have a small enough example to make a repo, and I sadly don't have the time to investigate that much. But what I can say when I mocked vee-validate/zod the error went away

sschneider-ihre-pvs avatar Feb 08 '22 08:02 sschneider-ihre-pvs

Probably related to the stuff you are getting. Closing till we figure out a reproducable sample.

logaretm avatar Feb 21 '23 08:02 logaretm

@logaretm This seems to happen when modeling readonly objects. I fixed it in my use case by cloning the selection options before passing to the input. Ill try to create a reproduction.

joel-wenzel avatar Mar 11 '23 23:03 joel-wenzel