-
Notifications
You must be signed in to change notification settings - Fork 158
Labels
Description
Have you read the Troubleshooting section?
Yes
Plugin version
v7.6.6
ESLint version
v9.35.0
Node.js version
22.21.0
Bug description
When userEvent is re-exported from a custom module configured via testing-library/utils-module, some rules fail to detect it.
Steps to reproduce
Given this ESLint config:
{
settings: {
"testing-library/utils-module": "~/test-utils"
},
}And this test file:
import { userEvent, waitFor } from '~/test-utils';
test('example', async () => {
await waitFor(() => {
userEvent.click(element);
});
});Expected: no-wait-for-side-effects reports an error (same as fireEvent).
Error output/screenshots
A minimal failing test case can be added to no-wait-for-side-effects.test.ts:
// this should fail when added to valid
{
settings: { 'testing-library/utils-module': 'test-utils' },
code: `
import { userEvent, waitFor } from 'test-utils';
async function test() {
await waitFor(() => {
userEvent.click(element);
});
}
`,
errors: [{ messageId: 'noSideEffectsWaitFor' }],
}ESLint configuration
import testingLibrary from 'eslint-plugin-testing-library';
export default [
{
files: ['**/*.test.{ts,tsx}'],
...testingLibrary.configs['flat/react'],
settings: {
'testing-library/utils-module': 'test-utils',
},
},
];Rule(s) affected
- no-wait-for-side-effects
- no-await-sync-events
- await-async-events
- prefer-user-event-setup
Anything else?
No response
Do you want to submit a pull request to fix this bug?
Yes
Reactions are currently unavailable