Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[WNMGDS-3182] Updates two @testing-library dependencies #3458

Open
wants to merge 39 commits into
base: jryan/react-18-upgrade
Choose a base branch
from

Conversation

kim-cmsds
Copy link
Collaborator

Summary

  • Jira Ticket
  • At a high-level, this PR upgrades @testing-library/preact, @testing-library/react, and @testing-library/user-event and removes @testing-library/preact-hooks and @testing-library/react-hooks.
  • The user-event api changes from v13 to v14 means that any userEvent.click is now a promise that needs to be awaited and the docs recommend invoking a single session that more closely replicates user behavior

How to test

  1. Pull down this branch locally and run npm install
  2. Run npm run test:unit, npm run test:unit:wc, and npm run test:unit:preact
  3. Note: there will most likely be two tests that are failing while running the preact tests (one is consistent with what's on main and another is a new issue with the useClickOutsideHandler.test.tsx test. I do not propose either should block this work but open to feedback.

Checklist

  • Prefixed the PR title with the Jira ticket number as [WNMGDS-####] Title or [NO-TICKET] if this is unticketed work.
  • Selected appropriate Type (only one) label for this PR, if it is a breaking change, label should only be Type: Breaking
  • Selected appropriate Impacts, multiple can be selected.
  • Selected appropriate release milestone

If this is a change to code:

  • Created or updated unit tests to cover any new or modified code
  • Verified that running both npm run test:unit and npm run test:browser:all were each successful
  • If necessary, updated unit-test snapshots (npm run test:unit:update) and browser-test snapshots (npm run test:browser:all:update)

…ecause v14 of `@testing-library/user-event` only passes along `key`
@kim-cmsds kim-cmsds added Type: Internal This item relates to internal tooling/maintenance dependencies Pull requests that update a dependency file labels Feb 27, 2025
@kim-cmsds kim-cmsds added this to the 12.2.0 milestone Feb 27, 2025
Copy link
Collaborator

@jack-ryan-nava-pbc jack-ryan-nava-pbc left a comment

Choose a reason for hiding this comment

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

Some questions, but super close!

@@ -6,8 +6,7 @@ const usePreact = Boolean(JSON.parse(process.env.PREACT ?? 'true'));
const preactAliases = usePreact
? {
react: 'preact/compat',
'react-dom/test-utils': 'preact/test-utils',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wait, why did these go away?

@@ -121,11 +124,11 @@ describe('SingleInputDateField', function () {
// https://github.com/testing-library/dom-testing-library/issues/774#issuecomment-702574312
// but it isn't working
//
// it('selecting a day calls onChange', () => {
// it('selecting a day calls onChange', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test doesn't work even with the new version updates?

@@ -24,6 +27,11 @@ function expectInvalid(textField: HTMLElement) {
}

describe('DateInput', () => {
afterEach(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need this clean up for anytime we use fakeTimers, right? I think there are two tests that use fake timers but don't do this clean up. Is that ok?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like its: ChoiceList, ds-choice-list and IdleTimeout. Do those tests not need the cleanup for some reason?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
dependencies Pull requests that update a dependency file Type: Internal This item relates to internal tooling/maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants