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

chore: change test environment to jsdom #13149

Merged
merged 1 commit into from
Feb 16, 2021

Conversation

michael-s-molina
Copy link
Member

SUMMARY

Change test environment to jsdom (default when installed) so we can use react-testing-library functions that listen for DOM mutations like findBy.

Test environment with enzyme option was causing TypeError: MutationObserver is not a constructor

@ktmud @rusackas @geido

Add to #13079

TEST PLAN

1 - Execute all jest tests
2 - All tests should pass

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

Copy link
Member

@geido geido left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@rusackas rusackas merged commit 981deaa into apache:master Feb 16, 2021
@ktmud
Copy link
Member

ktmud commented Feb 16, 2021

Do you know what's the benefit of setting testEnv to enzyme and why changing it doesn't break existing enzyme tests?

@michael-s-molina
Copy link
Member Author

michael-s-molina commented Feb 17, 2021

@ktmud Setting testEnv to enzyme enables jest-environment-enzyme package. This package helps to configure Jest and React integration by setting enzyme adapter and adding React and enzyme to the global scope so we don't need to import them in our tests. As I can tell none of these benefits are being used because our tests are importing React and enzyme in test files and spec/helpers/shim.ts is configuring the adapter. Another thing that corroborates this thesis is that our tests successfully execute when we change testEnv to js-dom.

The error happens when testEnv equals enzyme because jest-environment-enzyme depends on js-dom 11.12.0 and MutationObserver was introduced in version 13.2.0. When we changed testEnv to js-dom the dependency used is 16.4.0 as you can see in the following image:

Screen Shot 2021-02-17 at 2 45 00 PM

@ktmud
Copy link
Member

ktmud commented Feb 17, 2021

Thanks for the clarification!

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XS test:component 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants