diff --git a/lib/rules/no-node-access.ts b/lib/rules/no-node-access.ts index d57e63ca..bfbbc346 100644 --- a/lib/rules/no-node-access.ts +++ b/lib/rules/no-node-access.ts @@ -73,7 +73,12 @@ export default createTestingLibraryRule({ ALL_PROHIBITED_MEMBERS.some( (allReturningNode) => allReturningNode === propertyName ) && - !EVENTS_SIMULATORS.some((simulator) => simulator === objectName) + ![ + ...EVENTS_SIMULATORS, + // TODO: As discussed in https://github.com/testing-library/eslint-plugin-testing-library/issues/1024, this is just a temporary workaround. + // We should address the root cause and implement a proper solution instead of explicitly excluding 'user' here. + 'user', + ].some((simulator) => simulator === objectName) ) { if (allowContainerFirstChild && propertyName === 'firstChild') { return; diff --git a/tests/lib/rules/no-node-access.test.ts b/tests/lib/rules/no-node-access.test.ts index fab437d4..32960944 100644 --- a/tests/lib/rules/no-node-access.test.ts +++ b/tests/lib/rules/no-node-access.test.ts @@ -163,6 +163,16 @@ ruleTester.run(RULE_NAME, rule, { expect(screen.getByText('SomeComponent')).toBeInTheDocument(); `, }, + { + code: ` + import userEvent from '@testing-library/user-event'; + import { screen } from '${testingFramework}'; + + const buttonText = screen.getByText('submit'); + const user = userEvent.setup(); + user.click(buttonText); + `, + }, ...EVENTS_SIMULATORS.map((simulator) => ({ code: ` import { screen } from '${testingFramework}';