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

Exception when test dispatchEvent with jsdom #791

Closed
6 tasks done
hellodresji opened this issue Feb 18, 2022 · 0 comments · Fixed by #793
Closed
6 tasks done

Exception when test dispatchEvent with jsdom #791

hellodresji opened this issue Feb 18, 2022 · 0 comments · Fixed by #793
Labels
good first issue Good for newcomers

Comments

@hellodresji
Copy link

Describe the bug

I have two tests to test dispatching a event on a dom with jsdom:

  1. use default Event to instantiate a click event
  2. use Event from window object created by jsdom to instantiate a click event
    image
    First test failed because of TypeError: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'. and second passed.
    It seems the jsdom is not correctly provided for test environment.

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-8arlh8?file=package.json&initialPath=__vitest__

It works in the repro within StackBlitz, but it always fails locally.

System Info

System:
    OS: Windows 10 10.0.19042
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
    Memory: 1.93 GB / 15.67 GB
Binaries:
    Node: 16.14.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.14.15 - C:\Program Files\nodejs\npm.CMD
Browsers:
    Chrome: 98.0.4758.102
npmPackages:
    vite: latest => 2.8.4 
    vitest: latest => 0.4.1

Used Package Manager

pnpm

Validations

@hellodresji hellodresji changed the title Exception when test dispatchEvent with JSD Exception when test dispatchEvent with jsdom Feb 18, 2022
@sheremet-va sheremet-va added bug good first issue Good for newcomers labels Feb 18, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants