-
Notifications
You must be signed in to change notification settings - Fork 153
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
Have you read the Troubleshooting section?
Yes
Plugin version
6.0.0
ESLint version
8.47.0
Node.js version
18.16.0
package manager and version
9.7.1
Operating system
macOS Ventura 13.4.1(22F82)
Bug description
Following the instructions in the custom-render section, I have created a test-utils.ts file and re-exported '@testing-library/react' within it to utilize the API of '@testing-library/react'. However, it seems that the ESLint plugin's ability to detect the "no-node-access" error becomes inconsistent when using imports from '@testing-library/react'.
test-utils.ts
import { ThemeProvider } from '@mui/material';
import { RenderOptions, render } from '@testing-library/react';
const AllTheProviders: React.FC<{ children: React.ReactNode }> = ({ children }) => (
<ThemeProvider theme={theme}>{children}</ThemeProvider>
);
const customRender = (ui: React.ReactElement, options?: Omit<RenderOptions, 'wrapper'>) =>
render(ui, { wrapper: AllTheProviders, ...options });
export * from '@testing-library/react';
export { customRender as render };
2023-08-17.21.36.53.mov
Steps to reproduce
- Create a test-utils.ts file as directed in the custom-render section.
- Inside the test-utils.ts file, export '@testing-library/react' and utilize its APIs.
- Observe the ESLint behavior regarding the "no-node-access" error when using imports from '@testing-library/react' within this context.
Error output/screenshots
No response
ESLint configuration
{
"extends": [
"next/core-web-vitals",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"rules": {
"prefer-template": "error"
},
"overrides": [
{
"files": ["*.test.{ts,tsx}"],
"extends": ["plugin:jest/recommended", "plugin:testing-library/react"]
}
]
}
Rule(s) affected
"overrides": [
{
"files": ["*.test.{ts,tsx}"],
"extends": ["plugin:jest/recommended", "plugin:testing-library/react"]
}
]
Anything else?
No response
Do you want to submit a pull request to fix this bug?
No
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested