@@ -149,6 +149,10 @@ ruleTester.run(RULE_NAME, rule, {
149
149
column : 31 ,
150
150
} ,
151
151
] ,
152
+ output : `async () => {
153
+ const element = ${ query } ('foo')
154
+ }
155
+ ` ,
152
156
} ) ) ,
153
157
// custom sync queries with await operator are not valid
154
158
{
@@ -158,6 +162,11 @@ ruleTester.run(RULE_NAME, rule, {
158
162
}
159
163
` ,
160
164
errors : [ { messageId : 'noAwaitSyncQuery' , line : 3 , column : 31 } ] ,
165
+ output : `
166
+ async () => {
167
+ const element = getByIcon('search')
168
+ }
169
+ ` ,
161
170
} ,
162
171
{
163
172
code : `
@@ -166,6 +175,11 @@ ruleTester.run(RULE_NAME, rule, {
166
175
}
167
176
` ,
168
177
errors : [ { messageId : 'noAwaitSyncQuery' , line : 3 , column : 31 } ] ,
178
+ output : `
179
+ async () => {
180
+ const element = queryByIcon('search')
181
+ }
182
+ ` ,
169
183
} ,
170
184
{
171
185
code : `
@@ -174,6 +188,11 @@ ruleTester.run(RULE_NAME, rule, {
174
188
}
175
189
` ,
176
190
errors : [ { messageId : 'noAwaitSyncQuery' , line : 3 , column : 38 } ] ,
191
+ output : `
192
+ async () => {
193
+ const element = screen.getAllByIcon('search')
194
+ }
195
+ ` ,
177
196
} ,
178
197
{
179
198
code : `
@@ -182,6 +201,11 @@ ruleTester.run(RULE_NAME, rule, {
182
201
}
183
202
` ,
184
203
errors : [ { messageId : 'noAwaitSyncQuery' , line : 3 , column : 38 } ] ,
204
+ output : `
205
+ async () => {
206
+ const element = screen.queryAllByIcon('search')
207
+ }
208
+ ` ,
185
209
} ,
186
210
// sync queries with await operator inside assert are not valid
187
211
...SYNC_QUERIES_COMBINATIONS . map < RuleInvalidTestCase > ( ( query ) => ( {
@@ -196,6 +220,10 @@ ruleTester.run(RULE_NAME, rule, {
196
220
column : 22 ,
197
221
} ,
198
222
] ,
223
+ output : `async () => {
224
+ expect( ${ query } ('foo')).toBeEnabled()
225
+ }
226
+ ` ,
199
227
} ) ) ,
200
228
201
229
// sync queries in screen with await operator are not valid
@@ -211,6 +239,10 @@ ruleTester.run(RULE_NAME, rule, {
211
239
column : 38 ,
212
240
} ,
213
241
] ,
242
+ output : `async () => {
243
+ const element = screen.${ query } ('foo')
244
+ }
245
+ ` ,
214
246
} ) ) ,
215
247
216
248
// sync queries in screen with await operator inside assert are not valid
@@ -226,6 +258,10 @@ ruleTester.run(RULE_NAME, rule, {
226
258
column : 29 ,
227
259
} ,
228
260
] ,
261
+ output : `async () => {
262
+ expect( screen.${ query } ('foo')).toBeEnabled()
263
+ }
264
+ ` ,
229
265
} ) ) ,
230
266
231
267
// sync query awaited and related to testing library module
@@ -240,6 +276,12 @@ ruleTester.run(RULE_NAME, rule, {
240
276
}
241
277
` ,
242
278
errors : [ { messageId : 'noAwaitSyncQuery' , line : 4 , column : 38 } ] ,
279
+ output : `
280
+ import { screen } from '${ testingFramework } '
281
+ () => {
282
+ const element = screen.getByRole('button')
283
+ }
284
+ ` ,
243
285
} )
244
286
) ,
245
287
// sync query awaited and related to custom module is not valid
@@ -252,6 +294,12 @@ ruleTester.run(RULE_NAME, rule, {
252
294
}
253
295
` ,
254
296
errors : [ { messageId : 'noAwaitSyncQuery' , line : 4 , column : 38 } ] ,
297
+ output : `
298
+ import { screen } from 'test-utils'
299
+ () => {
300
+ const element = screen.getByRole('button')
301
+ }
302
+ ` ,
255
303
} ,
256
304
257
305
// awaited custom sync query matching custom-queries setting is invalid
@@ -265,6 +313,24 @@ ruleTester.run(RULE_NAME, rule, {
265
313
})
266
314
` ,
267
315
errors : [ { messageId : 'noAwaitSyncQuery' , line : 3 , column : 31 } ] ,
316
+ output : `
317
+ test('A valid example test', async () => {
318
+ const element = queryByIcon('search')
319
+ })
320
+ ` ,
321
+ } ,
322
+ {
323
+ code : `
324
+ test('A valid example test', async () => {
325
+ const element = await(screen.getByRole('button'))
326
+ })
327
+ ` ,
328
+ errors : [ { messageId : 'noAwaitSyncQuery' , line : 3 , column : 38 } ] ,
329
+ output : `
330
+ test('A valid example test', async () => {
331
+ const element = (screen.getByRole('button'))
332
+ })
333
+ ` ,
268
334
} ,
269
335
] ,
270
336
} ) ;
0 commit comments