Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mocked onClick changing the contents of it's event #7567

Open
6 tasks done
sterlingwalsh opened this issue Feb 26, 2025 · 2 comments
Open
6 tasks done

mocked onClick changing the contents of it's event #7567

sterlingwalsh opened this issue Feb 26, 2025 · 2 comments

Comments

@sterlingwalsh
Copy link

sterlingwalsh commented Feb 26, 2025

Describe the bug

In an onclick event the currentTarget value is being altered (removed). Reproduction in codesandbox below. Extracting the event from the mocked implementation of the function itself has a value for the currentTarget property. In the mock.calls or mock.lastCall property on the mock itself, however, the currentTarget value has been removed. It is being changed within the reference of the event itself somehow as can be seen by both the expect().isEqual and expect().toBe tests.

Expected behavior: event remains consistent.

Reproduction

https://codesandbox.io/p/devbox/lingering-sunset-7m8gzm?file=%2Fsrc%2Fitem.test.tsx%3A26%2C44

System Info

System:
    OS: Linux 6.1 Ubuntu 20.04.6 LTS (Focal Fossa)
    CPU: (2) x64 AMD EPYC
    Memory: 1.78 GB / 4.14 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 20.12.1 - /home/codespace/nvm/current/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 10.5.0 - /home/codespace/nvm/current/bin/npm
    pnpm: 8.15.6 - /home/codespace/nvm/current/bin/pnpm
  npmPackages:
    @vitejs/plugin-react: ^2.0.0 => 2.0.0 
    vite: ^3.0.0 => 3.0.0 
    vitest: ^0.21.1 => 0.21.1

Used Package Manager

npm

Validations

@hi-ogawa
Copy link
Contributor

npmPackages:
@vitejs/plugin-react: ^2.0.0 => 2.0.0
vite: ^3.0.0 => 3.0.0
vitest: ^0.21.1 => 0.21.1

The dependencies are quite old. Can you test with the latest version Vite 6 + Vitest 3?

Copy link

Hello @sterlingwalsh. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants