Skip to content

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

Open

Description

@rubenslopes

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.

Activity

  1. samselikoff commented on Aug 13, 2020

    @samselikoff
    Contributor

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

    What version of node?

  2. ryanto commented on Aug 13, 2020

    @ryanto

    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

  3. rubens-lopes commented on Aug 13, 2020

    @rubens-lopes

    12.18.3

  4. mathiasgheno commented on Jan 25, 2021

    @mathiasgheno

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

  5. chazmcgrill commented on Nov 24, 2021

    @chazmcgrill

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions