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

test: add React Testing Library #11771

Merged
merged 3 commits into from
Dec 1, 2020
Merged

test: add React Testing Library #11771

merged 3 commits into from
Dec 1, 2020

Conversation

ktmud
Copy link
Member

@ktmud ktmud commented Nov 21, 2020

SUMMARY

Implement [SIP-56] Adopt React Testing Library for testing React components.

  • Add React Testing Library
  • Updated the setup files
  • Convert a couple of existing components with the new library

As demonstrated in the new code, with RTL, we are able to easily test the use of the useEffect hook with DOM updates, that is previously not possible to do in Enzyme. Just make sure to use waitFor to wait for the DOM change, otherwise you may encounter an update inside a test was not wrapped in act(...) errors.

Another lesson learned is that in order to use waitFor, you must explicitly add a jest-environment: jsdom docblock to the test file, because the default jest environment jest-enzyme is incompatible with RTL.

/**
 * @jest-environment jsdom
 */

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TEST PLAN

CI

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

@codecov-io
Copy link

codecov-io commented Nov 21, 2020

Codecov Report

Merging #11771 (54e905c) into master (872a54d) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #11771   +/-   ##
=======================================
  Coverage   67.29%   67.29%           
=======================================
  Files         905      905           
  Lines       43862    43862           
  Branches     4201     4201           
=======================================
  Hits        29519    29519           
  Misses      14239    14239           
  Partials      104      104           
Flag Coverage Δ
cypress 55.12% <100.00%> (ø)
javascript 62.86% <100.00%> (+0.01%) ⬆️
python 63.64% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset-frontend/src/components/Label/index.tsx 100.00% <ø> (ø)
superset-frontend/src/components/Timer.tsx 95.83% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 872a54d...ae3f033. Read the comment docs.

Copy link

@graceguo-supercat graceguo-supercat left a comment

Choose a reason for hiding this comment

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

LGTM

@ktmud ktmud merged commit a5af2ad into master Dec 1, 2020
@ktmud ktmud deleted the add-react-testing-library branch December 11, 2020 01:43
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.0.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 🚢 1.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants