Skip to content

fix nested acts - #1468

Open
snowystinger wants to merge 1 commit into
testing-library:mainfrom
snowystinger:fix-nested-acts
Open

fix nested acts#1468
snowystinger wants to merge 1 commit into
testing-library:mainfrom
snowystinger:fix-nested-acts

Conversation

@snowystinger

Copy link
Copy Markdown

What:

Closes #1231
And removes the need for testing-library/user-event#1283

Why:

testing-library/user-event#1283

In React, nested synchronous act calls can prematurely teardown the act queue creating console warnings.

How:

By tracking if we're already inside an act, we can avoid wrapping it in a new one. At the same time, we can keep the wrapper around all events, which is an expectation using testing library's configure

Checklist:

  • Documentation added to the N/A
    docs site
  • Tests
  • TypeScript definitions updated N/A
  • Ready to be merged

Originally I was going to make this change over in user event, we have two PRs to do it, however, it's really a React and Preact concern. Changing it in User Event would affect everyone. Angular testing library already wraps all events for a different reason and so removing an event from that callback wrapper could be unexpected or breaking. I would guess this change is also needed in the Preact testing library repo as well.

@codesandbox-ci

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 899769f:

Sandbox Source
react-testing-library-examples Configuration

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.

'event was not wrapped in act' warning with React 18, react-datepicker and user.type

1 participant