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

ci: Prevent future enzyme imports with pre-commit lint rule #8219

Closed
wants to merge 1 commit into from

Conversation

Cal-L
Copy link
Contributor

@Cal-L Cal-L commented Jan 8, 2024

Description

This change is intended to prevent future imports of enzyme since it has not been maintained React 16. The recommended unit testing library for components is to use is React Testing Library. This is enforced by adding the no-restricted-imports lint rule on pre-commit that lets devs know to use RTL instead.

Caveat - If an existing file using enzyme is changed, the lint rule will fail on the commit command. Since most of our component test files are lightweight, devs should try their best to update the changed file to use RTL.

Next iteration - Retype enzyme import to show strikeout on usage (deprecate)

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

enzyme-lint.mov

Before

After

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@Cal-L Cal-L requested a review from a team as a code owner January 8, 2024 18:32
Copy link
Contributor

github-actions bot commented Jan 8, 2024

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@Cal-L Cal-L added team-mobile-client No QA Needed Apply this label when your PR does not need any QA effort. labels Jan 8, 2024
@metamaskbot metamaskbot added the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Jan 8, 2024
@Cal-L Cal-L requested a review from a team as a code owner January 8, 2024 21:03
@MetaMask MetaMask deleted a comment from github-actions bot Jan 8, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jan 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (445ef2b) 39.65% compared to head (81e864e) 39.65%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8219   +/-   ##
=======================================
  Coverage   39.65%   39.65%           
=======================================
  Files        1233     1233           
  Lines       29820    29820           
  Branches     2840     2840           
=======================================
  Hits        11824    11824           
  Misses      17307    17307           
  Partials      689      689           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MetaMask MetaMask deleted a comment from github-actions bot Jan 8, 2024
Copy link
Contributor

github-actions bot commented Jan 8, 2024

E2E test started on Bitrise: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/5d5dedfd-db08-40f9-b644-cc4a72d712d6
You can also kick off another Bitrise E2E smoke test by removing and re-applying the (Run Smoke E2E) label

Copy link

sonarcloud bot commented Jan 8, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link
Contributor

@NicolasMassart NicolasMassart left a comment

Choose a reason for hiding this comment

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

I think this is really needed, thanks.
The fact that it requires to update tests when we modify a file is, most of the times, not a big deal as test is only just a snapshot match. Very few tests use Enzyme and have extended logic at the same time.

Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

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

Not sure why this requires design system review

@desi
Copy link
Contributor

desi commented Jan 10, 2024

@georgewrmarshall I figured it out. We had believed the CODEOWNER rule had triggered us for review on this one hence why we were confused but it looks like @Cal-L was actually requesting it (not CODEOWNERS) and was likely just making sure our team saw this change.

@Cal-L Cal-L added the DO-NOT-MERGE Pull requests that should not be merged label Jan 11, 2024
@Cal-L
Copy link
Contributor Author

Cal-L commented Jan 11, 2024

Added do not merge label - Will sync with @pedronfigueiredo to explore fitness functions instead

@Cal-L
Copy link
Contributor Author

Cal-L commented Jan 11, 2024

@georgewrmarshall I figured it out. We had believed the CODEOWNER rule had triggered us for review on this one hence why we were confused but it looks like @Cal-L was actually requesting it (not CODEOWNERS) and was likely just making sure our team saw this change.

Hm.. I didn't explicitly request review from DS. There might be something happening in the automation. cc @desi

@metamaskbot metamaskbot added in-progress and removed needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) labels Jan 16, 2024
@Cal-L Cal-L removed DO-NOT-MERGE Pull requests that should not be merged No QA Needed Apply this label when your PR does not need any QA effort. in-progress labels Jan 17, 2024
@metamaskbot metamaskbot added needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) in-progress and removed needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) labels Jan 17, 2024
@Cal-L
Copy link
Contributor Author

Cal-L commented Feb 29, 2024

Closing in favor of fitness function PR - #8789

@Cal-L Cal-L closed this Feb 29, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants