@@ -88,6 +88,13 @@ const FIRE_EVENT_FUNCTIONS = [
88
88
'gotPointerCapture' ,
89
89
'lostPointerCapture' ,
90
90
] ;
91
+ const SUPPORTED_TESTING_FRAMEWORKS = [
92
+ '@testing-library/dom' ,
93
+ '@testing-library/angular' ,
94
+ '@testing-library/react' ,
95
+ '@testing-library/vue' ,
96
+ '@marko/testing-library' ,
97
+ ] ;
91
98
const USER_EVENT_SYNC_FUNCTIONS = [
92
99
'clear' ,
93
100
'click' ,
@@ -168,15 +175,17 @@ ruleTester.run(RULE_NAME, rule, {
168
175
} ,
169
176
170
177
// valid tests for fire-event when only user-event set in eventModules
171
- ...FIRE_EVENT_FUNCTIONS . map ( ( func ) => ( {
172
- code : `
173
- import { fireEvent } from '@testing-library/framework';
174
- test('should not report fireEvent.${ func } sync event awaited', async() => {
175
- await fireEvent.${ func } ('foo');
176
- });
177
- ` ,
178
- options : [ { eventModules : [ 'user-event' ] } ] ,
179
- } ) ) ,
178
+ ...SUPPORTED_TESTING_FRAMEWORKS . flatMap ( ( testingFramework ) =>
179
+ FIRE_EVENT_FUNCTIONS . map ( ( func ) => ( {
180
+ code : `
181
+ import { fireEvent } from '@testing-library/${ testingFramework } ';
182
+ test('should not report fireEvent.${ func } sync event awaited', async() => {
183
+ await fireEvent.${ func } ('foo');
184
+ });
185
+ ` ,
186
+ options : [ { eventModules : [ 'user-event' ] } ] ,
187
+ } ) )
188
+ ) ,
180
189
181
190
// valid tests for user-event when only fire-event set in eventModules
182
191
...USER_EVENT_SYNC_FUNCTIONS . map ( ( func ) => ( {
@@ -192,24 +201,26 @@ ruleTester.run(RULE_NAME, rule, {
192
201
193
202
invalid : [
194
203
// sync fireEvent methods with await operator are not valid
195
- ...FIRE_EVENT_FUNCTIONS . map (
196
- ( func ) =>
197
- ( {
198
- code : `
199
- import { fireEvent } from '@testing-library/framework';
204
+ ...SUPPORTED_TESTING_FRAMEWORKS . flatMap ( ( testingFramework ) =>
205
+ FIRE_EVENT_FUNCTIONS . map (
206
+ ( func ) =>
207
+ ( {
208
+ code : `
209
+ import { fireEvent } from '@testing-library/${ testingFramework } ';
200
210
test('should report fireEvent.${ func } sync event awaited', async() => {
201
211
await fireEvent.${ func } ('foo');
202
212
});
203
213
` ,
204
- errors : [
205
- {
206
- line : 4 ,
207
- column : 17 ,
208
- messageId : 'noAwaitSyncEvents' ,
209
- data : { name : `fireEvent.${ func } ` } ,
210
- } ,
211
- ] ,
212
- } as const )
214
+ errors : [
215
+ {
216
+ line : 4 ,
217
+ column : 17 ,
218
+ messageId : 'noAwaitSyncEvents' ,
219
+ data : { name : `fireEvent.${ func } ` } ,
220
+ } ,
221
+ ] ,
222
+ } as const )
223
+ )
213
224
) ,
214
225
// sync userEvent sync methods with await operator are not valid
215
226
...USER_EVENT_SYNC_FUNCTIONS . map (
@@ -234,25 +245,27 @@ ruleTester.run(RULE_NAME, rule, {
234
245
235
246
// sync fireEvent methods with await operator are not valid
236
247
// when only fire-event set in eventModules
237
- ...FIRE_EVENT_FUNCTIONS . map (
238
- ( func ) =>
239
- ( {
240
- code : `
241
- import { fireEvent } from '@testing-library/framework';
248
+ ...SUPPORTED_TESTING_FRAMEWORKS . flatMap ( ( testingFramework ) =>
249
+ FIRE_EVENT_FUNCTIONS . map (
250
+ ( func ) =>
251
+ ( {
252
+ code : `
253
+ import { fireEvent } from '@testing-library/${ testingFramework } ';
242
254
test('should report fireEvent.${ func } sync event awaited', async() => {
243
255
await fireEvent.${ func } ('foo');
244
256
});
245
257
` ,
246
- options : [ { eventModules : [ 'fire-event' ] } ] ,
247
- errors : [
248
- {
249
- line : 4 ,
250
- column : 17 ,
251
- messageId : 'noAwaitSyncEvents' ,
252
- data : { name : `fireEvent.${ func } ` } ,
253
- } ,
254
- ] ,
255
- } as const )
258
+ options : [ { eventModules : [ 'fire-event' ] } ] ,
259
+ errors : [
260
+ {
261
+ line : 4 ,
262
+ column : 17 ,
263
+ messageId : 'noAwaitSyncEvents' ,
264
+ data : { name : `fireEvent.${ func } ` } ,
265
+ } ,
266
+ ] ,
267
+ } as const )
268
+ )
256
269
) ,
257
270
// sync userEvent sync methods with await operator are not valid
258
271
// when only fire-event set in eventModules
0 commit comments