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: begin the switch to RTL #945

Open
wants to merge 16 commits into
base: staging
Choose a base branch
from
Open

test: begin the switch to RTL #945

wants to merge 16 commits into from

Conversation

mvadari
Copy link
Collaborator

@mvadari mvadari commented Feb 22, 2024

High Level Overview of Change

This PR introduces the React Testing Library (RTL) to the Explorer's testing system, beginning the rollout of replacing Enzyme. It is a more modern testing library, and supports later versions of React.

Three test files are switched over to use RTL: Account, Currency, and Amount.

Only tests are affected by this change.

Context of Change

This switch is necessary to upgrade to React v18 (#668), which has a lot of features that would clean up the codebase a lot. Enzyme stopped supporting React at v16, and even v17 support requires a hacky adapter.

This PR replaces #530 - merge commits got messy and complicated, and it was easier to re-apply all the changes to the updated codebase.

Type of Change

  • Tests (You added tests for code that already exists, or your new feature included in this PR)

Codebase Modernization

  • Updated files to React Hooks
  • Updated files to TypeScript
  • Updated tests to React Testing Library

Test Plan

Tests pass locally and in CI.

Future Tasks

There are a total of 149 test files - not all of them use enzyme, but most do. This PR switches 3 of them over to RTL, to provide a template. The rest of the enzyme tests still need to be switched over.

A script could likely be written to handle most of the migration.

@mvadari mvadari mentioned this pull request Feb 22, 2024
9 tasks
@mvadari mvadari mentioned this pull request Apr 9, 2024
2 tasks
@mvadari
Copy link
Collaborator Author

mvadari commented Apr 10, 2024

Tests should be resolved by #972

mvadari added a commit that referenced this pull request Apr 16, 2024
## High Level Overview of Change

This PR fixes the `LedgersPage` tests so they stop failing
intermittently/in some PRs (like #945).

### Context of Change

The `LedgersPage` tests fail for me locally.

![image](https://github.com/ripple/explorer/assets/8029314/f125f0b4-fa3d-4ca9-884f-a3d79637779e)

### Type of Change

- [x] Bug fix (non-breaking change which fixes an issue)
- [x] Tests (You added tests for code that already exists, or your new
feature included in this PR)

### TypeScript/Hooks Update

N/A - too complicated, not worth doing here.

## Test Plan

Tests pass locally now.
@mvadari mvadari marked this pull request as ready for review April 18, 2024 20:52
@mvadari
Copy link
Collaborator Author

mvadari commented Apr 18, 2024

Opening this PR (finally) now that the testing issue has been resolved

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

Successfully merging this pull request may close these issues.

2 participants