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: Cannot access 'observer' before initialization #621

Closed
dominikzogg opened this issue Mar 24, 2020 · 2 comments
Closed

ReferenceError: Cannot access 'observer' before initialization #621

dominikzogg opened this issue Mar 24, 2020 · 2 comments

Comments

@dominikzogg
Copy link

dominikzogg commented Mar 24, 2020

  • @testing-library/react version:
  • react version: 16.13.1
  • node version: 13.11.0
  • npm (or yarn) version: 6.13.7

Relevant code or config:

https://github.com/chubbyphp/petstore-react/blob/master/src/__tests__/Component/Form/PetForm.test.tsx

What you did:

npm test -- --watchAll

What happened:

petstore-react/node_modules/@testing-library/dom/dist/wait-for.js:41
      (0, _helpers.setImmediate)(() => observer.disconnect());
                                                ^

ReferenceError: Cannot access 'observer' before initialization
    at Immediate.<anonymous> (/home/schreiner/Documents/webpages/petstore-react/node_modules/@testing-library/dom/dist/wait-for.js:41:49)
    at processImmediate (internal/timers.js:456:21)
/home/schreiner/Documents/webpages/petstore-react/node_modules/@testing-library/dom/dist/wait-for.js:41
      (0, _helpers.setImmediate)(() => observer.disconnect());                                                ^ReferenceError: Cannot access 'observer' before initialization    at Immediate.<anonymous> (/home/schreiner/Documents/webpages/petstore-react/node_modules/@testing-library/dom/dist/wait-for.js:41:49)    at processImmediate (internal/timers.js:456:21)
TypeError: MutationObserver is not a constructor

      214 |     fireEvent.click(getByTestId('submit-pet'));
      215 | 
    > 216 |     await waitForElement(() =>
          |           ^
      217 |         getByTestId('submit-pet')
      218 |     );

Reproduction:

Run tests on: https://github.com/chubbyphp/petstore-react

Problem description:

This problem apears when upgrading to 10., worked well on 9.

Suggested solution:

@pushred
Copy link

pushred commented Mar 25, 2020

@dominikzogg looks like testing-library/dom-testing-library#477 is discussing this issue with different resolution options

@dominikzogg
Copy link
Author

@pushred thanks, adding jest-environment-jsdom-sixteen solved the issue

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

2 participants