Skip to content

Disallow calling configure inside of a test #997

New issue

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

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

Already on GitHub? Sign in to your account

Open
Janpot opened this issue Mar 19, 2025 · 3 comments
Open

Disallow calling configure inside of a test #997

Janpot opened this issue Mar 19, 2025 · 3 comments
Labels
new rule New rule to be included in the plugin

Comments

@Janpot
Copy link

Janpot commented Mar 19, 2025

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

@Janpot Janpot added new rule New rule to be included in the plugin triage Pending to be triaged by a maintainer labels Mar 19, 2025
@Belco90 Belco90 removed the triage Pending to be triaged by a maintainer label Mar 23, 2025
@Belco90
Copy link
Member

Belco90 commented Apr 30, 2025

Hi @Janpot. I'm checking the docs for the configure util and I don't see any reference in React or other Testing Library frameworks, so I believe this would only apply to DOM.

@Janpot
Copy link
Author

Janpot commented Apr 30, 2025

https://testing-library.com/docs/react-testing-library/api#configure

can't really speak for other libs, but searching on the docs for "configure" suggests other libs have this as well.

@Belco90
Copy link
Member

Belco90 commented Apr 30, 2025

@Janpot Good catch! I couldn't find anything under the Setup section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new rule New rule to be included in the plugin
Projects
None yet
Development

No branches or pull requests

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy