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

MessageEvent is not of type Event #1593

Closed
6 tasks done
dheardal opened this issue Jul 4, 2022 · 1 comment · Fixed by #1594
Closed
6 tasks done

MessageEvent is not of type Event #1593

dheardal opened this issue Jul 4, 2022 · 1 comment · Fixed by #1594

Comments

@dheardal
Copy link

dheardal commented Jul 4, 2022

Describe the bug

For a normal event this test runs fine:

fireEvent(window, new Event('message'));

However this:

fireEvent(window, new MessageEvent('message'));

throws:
TypeError: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.

This test worked previously when using jest

Reproduction

  • This is when using the jsdom envrionment

System Info

System:
    OS: macOS 12.3.1
    CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
    Memory: 186.50 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
    npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
    Watchman: 2022.02.21.00 - /usr/local/bin/watchman
  Browsers:
    Chrome: 103.0.5060.53
    Firefox: 95.0.2
    Safari: 15.4
  npmPackages:
    @vitejs/plugin-react: 1.3.2 => 1.3.2 
    vite: 2.9.13 => 2.9.13 
    vitest: 0.17.0 => 0.17.0

Used Package Manager

npm

Validations

@dheardal
Copy link
Author

dheardal commented Jul 4, 2022

For any others having this issue, this is a workaround:

const event = new Event('message');
(event as any).data = { test: 'test' }
fireEvent(window, event);

@github-actions github-actions bot locked and limited conversation to collaborators Jun 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants