@@ -181,6 +181,16 @@ ruleTester.run(RULE_NAME, rule, {
181
181
const buttonText = screen.getByText('submit');
182
182
const userAlias = userEvent.setup();
183
183
userAlias.click(buttonText);
184
+ ` ,
185
+ } ,
186
+ {
187
+ code : `
188
+ import userEvent from '@testing-library/user-event';
189
+ import { screen } from '${ testingFramework } ';
190
+ test('...', () => {
191
+ const buttonText = screen.getByText('submit');
192
+ (() => { click: userEvent.click(buttonText); })();
193
+ });
184
194
` ,
185
195
} ,
186
196
{
@@ -241,7 +251,6 @@ ruleTester.run(RULE_NAME, rule, {
241
251
} ,
242
252
{
243
253
code : `
244
- // case: custom module set but not imported using ${ testingFramework } (aggressive reporting limited)
245
254
import { screen } from '${ testingFramework } ';
246
255
247
256
const ui = {
@@ -251,6 +260,48 @@ ruleTester.run(RULE_NAME, rule, {
251
260
const select = ui.select.get();
252
261
expect(select).toHaveClass(selectClasses.select);
253
262
});
263
+ ` ,
264
+ } ,
265
+ {
266
+ settings : { 'testing-library/utils-module' : 'test-utils' } ,
267
+ code : `
268
+ // case: custom module set but not imported using ${ testingFramework } (aggressive reporting limited)
269
+ import { screen, render } from 'test-utils';
270
+ import MyComponent from './MyComponent'
271
+
272
+ test('...', async () => {
273
+ const { user } = render(<MyComponent />)
274
+ await user.click(screen.getByRole("button"))
275
+ });
276
+ ` ,
277
+ } ,
278
+ {
279
+ settings : { 'testing-library/utils-module' : 'test-utils' } ,
280
+ code : `
281
+ // case: custom module set but not imported using ${ testingFramework } (aggressive reporting limited)
282
+ import { screen, render } from 'test-utils';
283
+ import MyComponent from './MyComponent'
284
+
285
+ test('...', async () => {
286
+ const result = render(<MyComponent />)
287
+ await result.user.click(screen.getByRole("button"))
288
+ });
289
+ ` ,
290
+ } ,
291
+ {
292
+ settings : {
293
+ 'testing-library/utils-module' : 'TestUtils' ,
294
+ 'testing-library/custom-renders' : [ 'renderComponent' ] ,
295
+ } ,
296
+ code : `
297
+ // case: custom module set but not imported using ${ testingFramework } (aggressive reporting limited)
298
+ import { screen, renderComponent } from './TestUtils';
299
+ import MyComponent from './MyComponent'
300
+
301
+ test('...', async () => {
302
+ const result = renderComponent(<MyComponent />)
303
+ await result.user.click(screen.getByRole("button"))
304
+ });
254
305
` ,
255
306
} ,
256
307
]
0 commit comments