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

[STEP-9] TypeError: MutationObserver is not a constructor #1

Open
rubenslopes opened this issue Aug 5, 2020 · 5 comments
Open

[STEP-9] TypeError: MutationObserver is not a constructor #1

rubenslopes opened this issue Aug 5, 2020 · 5 comments

Comments

@rubenslopes
Copy link

rubenslopes commented Aug 5, 2020

I've tried to update outdated packages but it does not solved the problem

LOG

FAIL  src/tests/app.js
  ✕ it shows a message when there are no reminders (67ms)

  ● it shows a message when there are no reminders

    TypeError: MutationObserver is not a constructor

      12 |     visit("/")
    > 13 |     await waitForElementToBeRemoved(() => screen.getByText("Loading..."))
         |           ^
      14 | 
      15 |     expect(screen.getByText("All done!")).toBeInTheDocument()
      16 |   })

      at node_modules/@testing-library/dom/dist/wait-for.js:79:18
      at waitFor (node_modules/@testing-library/dom/dist/wait-for.js:42:10)
      at node_modules/@testing-library/dom/dist/wait-for.js:135:54
      at node_modules/@testing-library/react/dist/pure.js:58:22
      at node_modules/@testing-library/react/dist/act-compat.js:60:24
      at batchedUpdates$1 (node_modules/react-dom/cjs/react-dom.development.js:21856:12)
      at act (node_modules/react-dom/cjs/react-dom-test-utils.development.js:929:14)
      at node_modules/@testing-library/react/dist/act-compat.js:59:20
      at asyncAct (node_modules/@testing-library/react/dist/act-compat.js:38:14)
      at Object.asyncWrapper (node_modules/@testing-library/react/dist/pure.js:57:35)
      at waitForWrapper (node_modules/@testing-library/dom/dist/wait-for.js:135:35)
      at waitForElementToBeRemoved (node_modules/@testing-library/dom/dist/wait-for-element-to-be-removed.js:39:31)
      at Object.<anonymous> (src/tests/app.js:13:11)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        1.8s, estimated 2s
Ran all test suites.

Watch Usage: Press w to show more.
@samselikoff
Copy link
Contributor

Whoops, sorry I missed this! Wasn't subscribed to the repo.

What version of node?

@ryanto
Copy link

ryanto commented Aug 13, 2020

I've run into this before, maybe six months or so ago on another React project.

Issue iirc was jest's jsdom dependency does not have MutationObserver. I think maybe I just polyfilled it as a quickfix.

More info here: https://github.com/testing-library/dom-testing-library/releases/tag/v7.0.0

@rubens-lopes
Copy link

12.18.3

@mathiasgheno
Copy link

The solution for me was this one. I updated react-scripts to the latest version and it worked.

@chazmcgrill
Copy link

chazmcgrill commented Nov 24, 2021

Installing the jest-environment-jsdom-sixteen package and changing the test script worked for me, see issue

"test": "craco test --env=jest-environment-jsdom-sixteen",

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

No branches or pull requests

6 participants