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: Migrated Enzyme to RNTL in test files from component-library #9

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

devin-ai-integration[bot]
Copy link

Description

This PR migrates unit tests from Enzyme to React Native Testing Library (RNTL) for the following files:

  • app/component-library/components/Badges/Badge/foundation/BadgeBase/BadgeBase.test.tsx
  • app/component-library/components/Sheet/SheetHeader/SheetHeader.test.tsx

The reason for this change is to align with modern testing practices and improve test reliability. RNTL provides a more user-centric approach to testing, which can lead to more robust and maintainable tests.

The improvements include:

  • Updated test imports to use RNTL
  • Replaced Enzyme's shallow and mount with RNTL's render
  • Updated assertions to use RNTL's screen queries
  • Refactored tests to follow RNTL best practices

Related issues

Manual testing steps

  1. Navigate to the project root directory
  2. Run yarn test app/component-library/components/Badges/Badge/foundation/BadgeBase/BadgeBase.test.tsx
  3. Run yarn test app/component-library/components/Sheet/SheetHeader/SheetHeader.test.tsx
  4. Verify that all tests pass successfully

Screenshots/Recordings

Files changed

The output of git diff main shows changes in two files:

  1. app/component-library/components/Badges/Badge/foundation/BadgeBase/BadgeBase.test.tsx

    • Replaced Enzyme's shallow import with React Native Testing Library's render and screen
    • Updated test structure to use RNTL's render and screen methods
    • Added more detailed assertions to check for specific component properties and styles
  2. app/component-library/components/Sheet/SheetHeader/SheetHeader.test.tsx

    • Replaced Enzyme's shallow import with React Native Testing Library's render and screen
    • Added import for userEvent from '@testing-library/user-event'
    • Updated test structure to use RNTL's render, screen, and userEvent methods
    • Enhanced test cases to include more specific assertions and interaction testing

These changes reflect the migration from Enzyme to React Native Testing Library, improving the tests' reliability and alignment with modern testing practices.

Pre-merge author checklist

  • I've followed MetaMask Coding Standards.
  • I've completed the PR template to the best of my ability
  • 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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants