@@ -31,7 +31,7 @@ ruleTester.run(RULE_NAME, rule, {
3131 } ,
3232 {
3333 code : `
34- import { screen } from '@testing-library/react';
34+ import { screen } from '@testing-library/react';
3535
3636 const { getByText } = screen;
3737 const button = getByRole('button');
@@ -43,29 +43,57 @@ ruleTester.run(RULE_NAME, rule, {
4343 import { render, within } from '@testing-library/react';
4444
4545 const { getByLabelText } = render(<MyComponent />);
46- const signinModal = getByLabelText('Sign In');
47- within(signinModal ).getByPlaceholderText('Username');
46+ const signInModal = getByLabelText('Sign In');
47+ within(signInModal ).getByPlaceholderText('Username');
4848 ` ,
4949 } ,
5050 {
5151 code : `
52- // case: importing custom module
53- const closestButton = document.getElementById('submit-btn').closest('button');
54- expect(closestButton).toBeInTheDocument();
52+ // case: code not related to testing library at all
53+ ReactDOM.render(
54+ <CommProvider useDsa={false}>
55+ <ThemeProvider>
56+ <GlobalStyle />
57+ <Suspense fallback={<Loader />}>
58+ <AppLogin />
59+ </Suspense>
60+ </ThemeProvider>
61+ </CommProvider>,
62+
63+ document.getElementById('root')
64+ );
5565 ` ,
66+ } ,
67+ {
5668 settings : {
5769 'testing-library/utils-module' : 'test-utils' ,
5870 } ,
71+ code : `
72+ // case: custom module set but not imported (aggressive reporting limited)
73+ const closestButton = document.getElementById('submit-btn').closest('button');
74+ expect(closestButton).toBeInTheDocument();
75+ ` ,
76+ } ,
77+ {
78+ code : `
79+ // case: without importing TL (aggressive reporting skipped)
80+ const closestButton = document.getElementById('submit-btn')
81+ expect(closestButton).toBeInTheDocument();
82+ ` ,
5983 } ,
6084 ] ,
6185 invalid : [
6286 {
87+ settings : {
88+ 'testing-library/utils-module' : 'test-utils' ,
89+ } ,
6390 code : `
64- // case: without importing TL (aggressive reporting)
91+ // case: importing from custom module (aggressive reporting limited)
92+ import 'test-utils';
6593 const closestButton = document.getElementById('submit-btn')
6694 expect(closestButton).toBeInTheDocument();
6795 ` ,
68- errors : [ { messageId : 'noNodeAccess' , line : 3 } ] ,
96+ errors : [ { line : 4 , column : 38 , messageId : 'noNodeAccess' } ] ,
6997 } ,
7098 {
7199 code : `
@@ -75,9 +103,13 @@ ruleTester.run(RULE_NAME, rule, {
75103 ` ,
76104 errors : [
77105 {
106+ line : 4 ,
107+ column : 33 ,
78108 messageId : 'noNodeAccess' ,
79109 } ,
80110 {
111+ line : 4 ,
112+ column : 62 ,
81113 messageId : 'noNodeAccess' ,
82114 } ,
83115 ] ,
@@ -90,6 +122,8 @@ ruleTester.run(RULE_NAME, rule, {
90122 ` ,
91123 errors : [
92124 {
125+ line : 4 ,
126+ column : 18 ,
93127 messageId : 'noNodeAccess' ,
94128 } ,
95129 ] ,
@@ -117,6 +151,8 @@ ruleTester.run(RULE_NAME, rule, {
117151 ` ,
118152 errors : [
119153 {
154+ line : 4 ,
155+ column : 43 ,
120156 messageId : 'noNodeAccess' ,
121157 } ,
122158 ] ,
@@ -128,11 +164,7 @@ ruleTester.run(RULE_NAME, rule, {
128164 const { getByText } = render(<Example />)
129165 getByText('submit').closest('button');
130166 ` ,
131- errors : [
132- {
133- messageId : 'noNodeAccess' ,
134- } ,
135- ] ,
167+ errors : [ { line : 5 , column : 29 , messageId : 'noNodeAccess' } ] ,
136168 } ,
137169 {
138170 code : `
@@ -165,11 +197,7 @@ ruleTester.run(RULE_NAME, rule, {
165197 const buttonText = screen.getByText('submit');
166198 const button = buttonText.closest('button');
167199 ` ,
168- errors : [
169- {
170- messageId : 'noNodeAccess' ,
171- } ,
172- ] ,
200+ errors : [ { line : 5 , column : 35 , messageId : 'noNodeAccess' } ] ,
173201 } ,
174202 {
175203 code : `
@@ -181,6 +209,8 @@ ruleTester.run(RULE_NAME, rule, {
181209 ` ,
182210 errors : [
183211 {
212+ line : 6 ,
213+ column : 35 ,
184214 messageId : 'noNodeAccess' ,
185215 } ,
186216 ] ,
@@ -192,11 +222,7 @@ ruleTester.run(RULE_NAME, rule, {
192222 const { getByText } = render(<Example />)
193223 const button = getByText('submit').closest('button');
194224 ` ,
195- errors : [
196- {
197- messageId : 'noNodeAccess' ,
198- } ,
199- ] ,
225+ errors : [ { line : 5 , column : 44 , messageId : 'noNodeAccess' } ] ,
200226 } ,
201227 {
202228 code : `
0 commit comments