-
Notifications
You must be signed in to change notification settings - Fork 153
Closed
@WesSouza
Description
Have you read the Troubleshooting section?
Yes
Plugin version
v7.6.2
ESLint version
v9.31.0
Node.js version
v22.11.0
Bug description
When importing fireEvent
from a different package than directly from '@testing-library/react', no-node-access
complains that function calls should not directly access a node:
// @/testing/index.ts export * from '@testing-library/react';
// someTest.test.ts import { fireEvent, render, screen } from '@/testing'; // ... render(something); const button = await screen.findByTestId('some-button'); fireEvent.click(button); // ^ - Avoid direct Node access. Prefer using the methods from Testing Library. eslint testing-library/no-node-access
Steps to reproduce
- Create a file or package with
export * from '@testing-library/react';
- On a test file, replace the import from '@testing-library/react' with that file path or package
- Have a test calling an event from
fireEvent
, such asfireEvent.click
no-node-access
triggers
Error output/screenshots
Avoid direct Node access. Prefer using the methods from Testing Library. eslint testing-library/no-node-access
ESLint configuration
import testingLibrary from 'eslint-plugin-testing-library'; // ... export default [ // ... { files: ['**/*.test.*'], ...testingLibrary.configs['flat/react'], }, ];
Rule(s) affected
no-node-access
Anything else?
No response
Do you want to submit a pull request to fix this bug?
No