Skip to content

test: begin the switch to RTL#945

Merged
mvadari merged 29 commits intostagingfrom
rtl
May 15, 2025
Merged

test: begin the switch to RTL#945
mvadari merged 29 commits intostagingfrom
rtl

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

@mvadari mvadari requested review from achowdhry-ripple and removed request for ckniffen and jonathanlei March 27, 2025 18:46
@mvadari
Copy link
Collaborator Author

mvadari commented Mar 28, 2025

Resolving the build error is more easily done after #984

Copy link
Collaborator

@achowdhry-ripple achowdhry-ripple left a comment

Choose a reason for hiding this comment

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

thank you for this cleanup

@mvadari mvadari merged commit c723ba0 into staging May 15, 2025
4 checks passed
@mvadari mvadari deleted the rtl branch May 15, 2025 17:35
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.

3 participants