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

ReferenceError: queueMicrotask is not defined #9139

Closed
BlackGlory opened this issue Nov 6, 2019 · 2 comments · Fixed by #9140
Closed

ReferenceError: queueMicrotask is not defined #9139

BlackGlory opened this issue Nov 6, 2019 · 2 comments · Fixed by #9140

Comments

@BlackGlory
Copy link
Contributor

🐛 Bug Report

ReferenceError: queueMicrotask is not defined

To Reproduce

jsdom has not implemented queueMicrotask yet, so this is expected.

/**
 * @jest-environment jsdom
 */

test('queueMicrotask', () => {
  console.log(typeof window === 'undefined' ? process.version : 'jsdom') // jsdom
  console.log(queueMicrotask)
})

However, the node environment also cannot get the queueMicrotask, although the node environment has already implemented this function.

/**
 * @jest-environment node
 */

test('queueMicrotask', () => {
  console.log(typeof window === 'undefined' ? process.version : 'jsdom') // v12.13.0
  console.log(queueMicrotask)
})

Expected behavior

queueMicrotask is defined.

envinfo

  npmPackages:
    jest: ^24.9.0 => 24.9.0
@thymikee
Copy link
Collaborator

thymikee commented Nov 6, 2019

Looks like we need to inject queueMicrotask into globals of the Node environment. Would you like to send a PR? :) The code is here:
https://github.com/facebook/jest/blob/e3f4c65140f08a2ec81e5a8260704c1d201e33c1/packages/jest-environment-node/src/index.ts#L48-L55

SimenB pushed a commit that referenced this issue Nov 6, 2019
* Add global.queueMicrotask

Fix #9139

* jest-environment-node: Add queueMicrotask
@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 May 11, 2021
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