Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Rewrite unit tests in the manner of RTL #54

Merged
merged 5 commits into from
Feb 22, 2022

Conversation

MaySoMusician
Copy link
Collaborator

@MaySoMusician MaySoMusician commented Feb 22, 2022

May relate to #33
Follows up #50

  • Rewrite all unit tests in the manner of React Testing Library
    • __test__/util.ts removed. The functions we could add to this would be provided all by the functionalities of RTL (and their related libraries). We can recreate it when we need again.
  • Enzyme and the related packages uninstalled
  • Install @testing-library/user-event@^14.0.0-beta
    • This provides a user interaction session management via userEvent.setup(). It is useful because we can write tests as if an user actually controls a components in their browser, and is recommended in the doc.
    • They specify this version in their installation guide even now.
  • Remove @testing-library/dom from package.json
    • This document recommends not to specify their version in package.json, because it is automatically installed with @testing-library/react, and we should let the former's version be resolved by the latter.
    • This doesn't mean I uninstalled the /dom package. It's still here as I mentioned above.

@testing-library/user-event@^14.0.0-beta provides a user interaction session management
via `userEvent.setup()`. It is useful because we can write tests as if an user actually
controls a components in their browser, and is recommended in the doc.

Also I remove @testing-library/dom from package.json because it is automatically
installed with @testing-library/react, and we should let the former's version be
resolved by the latter.
cf: https://testing-library.com/docs/user-event/install
Note that this doesn't mean the former package gets uninstalled from the project.
isVisible can be replaced completely by Testing Library's `toBeVisible`
Functions we need for now could be provided by TL's functionalities
@MaySoMusician MaySoMusician requested a review from halsk February 22, 2022 01:13
Copy link
Member

@halsk halsk left a comment

Choose a reason for hiding this comment

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

LGTM!

@halsk halsk merged commit 35c4494 into main Feb 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants