@@ -31,7 +31,7 @@ ruleTester.run(RULE_NAME, rule, {
31
31
} ,
32
32
{
33
33
code : `
34
- import { screen } from '@testing-library/react';
34
+ import { screen } from '@testing-library/react';
35
35
36
36
const { getByText } = screen;
37
37
const button = getByRole('button');
@@ -43,29 +43,57 @@ ruleTester.run(RULE_NAME, rule, {
43
43
import { render, within } from '@testing-library/react';
44
44
45
45
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');
48
48
` ,
49
49
} ,
50
50
{
51
51
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
+ );
55
65
` ,
66
+ } ,
67
+ {
56
68
settings : {
57
69
'testing-library/utils-module' : 'test-utils' ,
58
70
} ,
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
+ ` ,
59
83
} ,
60
84
] ,
61
85
invalid : [
62
86
{
87
+ settings : {
88
+ 'testing-library/utils-module' : 'test-utils' ,
89
+ } ,
63
90
code : `
64
- // case: without importing TL (aggressive reporting)
91
+ // case: importing from custom module (aggressive reporting limited)
92
+ import 'test-utils';
65
93
const closestButton = document.getElementById('submit-btn')
66
94
expect(closestButton).toBeInTheDocument();
67
95
` ,
68
- errors : [ { messageId : 'noNodeAccess' , line : 3 } ] ,
96
+ errors : [ { line : 4 , column : 38 , messageId : 'noNodeAccess' } ] ,
69
97
} ,
70
98
{
71
99
code : `
@@ -75,9 +103,13 @@ ruleTester.run(RULE_NAME, rule, {
75
103
` ,
76
104
errors : [
77
105
{
106
+ line : 4 ,
107
+ column : 33 ,
78
108
messageId : 'noNodeAccess' ,
79
109
} ,
80
110
{
111
+ line : 4 ,
112
+ column : 62 ,
81
113
messageId : 'noNodeAccess' ,
82
114
} ,
83
115
] ,
@@ -90,6 +122,8 @@ ruleTester.run(RULE_NAME, rule, {
90
122
` ,
91
123
errors : [
92
124
{
125
+ line : 4 ,
126
+ column : 18 ,
93
127
messageId : 'noNodeAccess' ,
94
128
} ,
95
129
] ,
@@ -117,6 +151,8 @@ ruleTester.run(RULE_NAME, rule, {
117
151
` ,
118
152
errors : [
119
153
{
154
+ line : 4 ,
155
+ column : 43 ,
120
156
messageId : 'noNodeAccess' ,
121
157
} ,
122
158
] ,
@@ -128,11 +164,7 @@ ruleTester.run(RULE_NAME, rule, {
128
164
const { getByText } = render(<Example />)
129
165
getByText('submit').closest('button');
130
166
` ,
131
- errors : [
132
- {
133
- messageId : 'noNodeAccess' ,
134
- } ,
135
- ] ,
167
+ errors : [ { line : 5 , column : 29 , messageId : 'noNodeAccess' } ] ,
136
168
} ,
137
169
{
138
170
code : `
@@ -165,11 +197,7 @@ ruleTester.run(RULE_NAME, rule, {
165
197
const buttonText = screen.getByText('submit');
166
198
const button = buttonText.closest('button');
167
199
` ,
168
- errors : [
169
- {
170
- messageId : 'noNodeAccess' ,
171
- } ,
172
- ] ,
200
+ errors : [ { line : 5 , column : 35 , messageId : 'noNodeAccess' } ] ,
173
201
} ,
174
202
{
175
203
code : `
@@ -181,6 +209,8 @@ ruleTester.run(RULE_NAME, rule, {
181
209
` ,
182
210
errors : [
183
211
{
212
+ line : 6 ,
213
+ column : 35 ,
184
214
messageId : 'noNodeAccess' ,
185
215
} ,
186
216
] ,
@@ -192,11 +222,7 @@ ruleTester.run(RULE_NAME, rule, {
192
222
const { getByText } = render(<Example />)
193
223
const button = getByText('submit').closest('button');
194
224
` ,
195
- errors : [
196
- {
197
- messageId : 'noNodeAccess' ,
198
- } ,
199
- ] ,
225
+ errors : [ { line : 5 , column : 44 , messageId : 'noNodeAccess' } ] ,
200
226
} ,
201
227
{
202
228
code : `
0 commit comments