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

Disallow calling `configure` inside of a test

Open
#997 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Name for new rule

prefer-top-level-configure

Description of the new rule

Fail when configure is not called top-level

Testing Library feature

global configuration utility

Testing Library framework(s)

@testing-library/dom, @testing-library/react, perhaps others

What category of rule is this?

Warns about a potential error

Optional: other category of rule

No response

Code examples
import { configure } from '@testing-library/react'
test('some test', () => {
  // FAIL:
  configure({ reactStrictMode: true })

  // ...
})
import { configure } from '@testing-library/react'

// OK:
configure({ reactStrictMode: true })

test('some test', () => {
  // ...
})
Anything else?

No response

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

Yes

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 requested prefer-top-level-configure rule and the Testing Library global configuration utility, comparing the failing and OK examples for @testing-library/dom and @testing-library/react. Done means calls to configure inside a test are reported while top-level calls are accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, react, typescript
Domain
testing-qa, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 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.