testing-library / testing-library/eslint-plugin-testing-library

Lint for setting advanceTimers with user-event when using jest.useFakeTimers

Open
#979 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

new rule
Dominant language
TypeScript
Stars
1.1k
Forks
168
Avg merge
15h 44m
Merged PRs (30d)
14

Description

Name for new rule

advance-timers-with-fake-timers

Description of the new rule

Enforce using the advanceTimers option for user-event when using jest's useFakeTimers in order to prevent testing timeouts

Testing Library feature

user-event's advanceTimers option when using fake timers

Testing Library framework(s)

user-event (across any Testing Library framework that can use it)

What category of rule is this?

Warns about a potential error

Optional: other category of rule

No response

Code examples

Using fake timers within a test directly:

jest.useFakeTimers();
const user = userEvent.setup(); // Warn - advanceTimers not set
beforeEach(() => {
  jest.useFakeTimers()
});

test('some behavior with user action', async () => {
  const user = userEvent.setup(); // Warn - advanceTimers not set
  // Test behavior
})
Anything else?

No response

Do you want to submit a pull request to make the new rule?

No

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 with the issue's examples of jest.useFakeTimers and userEvent.setup, and inspect the repository's existing rule entry points and tests for conventions. Define the rule's handling of fake timers and the advanceTimers option across supported Testing Library frameworks; done means the supplied examples are reported correctly and valid configurations are accepted.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.