testing-library / testing-library/user-event

Add a way to clean up userEvent after a test

Open
#1,280 1 comment 0 reactions 0 assignees View on GitHub

@ph-fritsche is already working on this.

Since Feb 3, 2025.

  • #1270 by @ph-fritsche — open
enhancement
Dominant language
TypeScript
Stars
2.3k
Forks
258
PR merge metrics
No merged PRs in 30d

Description

Problem description

Introducing testing-library/user-event into a single test has started causing some unrelated tests to fail in another part of the codebase (tests dealing with focus specifically)

Suggested solution

It would be great if I could call userEvent.setup() in my test and then have a user.destroy() or userEvent.destroy() method to call after the test is complete

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the userEvent.setup() entry point and review linked pull request #1270, which is already addressing this request. Verify the intended cleanup behavior against the focus-related failures described in the issue; the work is complete when teardown can be used after a test without causing unrelated focus tests to fail.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.