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

[Bug]: jest-mock 29.2.0 does not allow spying on window.dispatchEvent anymore #13466

Closed
chbiel opened this issue Oct 18, 2022 · 3 comments · Fixed by #13472
Closed

[Bug]: jest-mock 29.2.0 does not allow spying on window.dispatchEvent anymore #13466

chbiel opened this issue Oct 18, 2022 · 3 comments · Fixed by #13472

Comments

@chbiel
Copy link

chbiel commented Oct 18, 2022

Version

29.2.0

Steps to reproduce

  1. Clone https://github.com/chbiel/jest-global-bug
  2. cd jest-global-bug

npm

  1. cp package-npm.json package.json && npm install && npm test => works
  2. rm package.json && rm package-lock.json && rm -rf node_modules && cp package-npm-broken.json package.json && npm install && npm test => does not work

yarn

  1. cp package-yarn.json package.json && npm install && npm test => works (i was not able to pin jest to 29.1 with yarn. always results in a broken dependency tree somehow. So I used the also working version 28)
  2. rm package.json && rm yarn.lock && rm -rf node_modules && cp package-yarn-broken.json package.json && npm install && npm test => does not work

Expected behavior

jest.spyOn(global.window, 'dispatchEvent'); does not throw an error dispatchEvent property does not exist.

Same with window.window and similar.

Actual behavior

jest.spyOn(global.window, 'dispatchEvent'); does throw an error dispatchEvent property does not exist after upgrading (I think) jest-mock to version 29.2.0.

I am not 100% sure but I think it's related to this change: #13398

Additional context

No response

Environment

System:
    OS: Linux 5.4 Ubuntu 20.04.5 LTS (Focal Fossa)
    CPU: (6) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
  Binaries:
    Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
    Yarn: 1.17.3 - /usr/bin/yarn
    npm: 8.3.0 - ~/.nvm/versions/node/v16.13.1/bin/npm
@SimenB
Copy link
Member

SimenB commented Oct 18, 2022

@staplespeter ^

@SimenB
Copy link
Member

SimenB commented Oct 18, 2022

https://github.com/facebook/jest/releases/tag/v29.2.1

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants