@@ -63,6 +63,21 @@ const validNonStrictTestCases: RuleValidTestCase[] = [
6363 });
6464 ` ,
6565 } ,
66+ {
67+ code : `
68+ import { act } from '@testing-library/react'
69+ import userEvent from '@testing-library/user-event'
70+
71+ test('valid case', async () => {
72+ const user = userEvent.setup();
73+
74+ await act(async () => {
75+ await user.click(element);
76+ stuffThatDoesNotUseRTL()
77+ });
78+ })
79+ ` ,
80+ } ,
6681] ;
6782
6883const validTestCases : RuleValidTestCase [ ] = [
@@ -245,6 +260,28 @@ const invalidStrictTestCases: RuleInvalidTestCase[] =
245260 } ,
246261 ] ,
247262 } ,
263+ {
264+ code : `
265+ import { act } from '${ testingFramework } '
266+ import userEvent from '@testing-library/user-event'
267+
268+ test('invalid case', async () => {
269+ const user = userEvent.setup();
270+
271+ await act(async () => {
272+ await user.click(element);
273+ stuffThatDoesNotUseRTL()
274+ });
275+ })
276+ ` ,
277+ errors : [
278+ {
279+ messageId : 'noUnnecessaryActTestingLibraryUtil' ,
280+ line : 8 ,
281+ column : 15 ,
282+ } ,
283+ ] ,
284+ } ,
248285 ] ) ;
249286
250287const invalidTestCases : RuleInvalidTestCase [ ] = [
@@ -566,6 +603,40 @@ const invalidTestCases: RuleInvalidTestCase[] = [
566603 { messageId : 'noUnnecessaryActEmptyFunction' , line : 8 , column : 9 } ,
567604 ] ,
568605 } ,
606+ {
607+ code : `
608+ import { act } from '@testing-library/react'
609+ import userEvent from '@testing-library/user-event'
610+
611+ test('invalid case', async () => {
612+ const user = userEvent.setup();
613+
614+ await act(async () => {
615+ await user.click(element);
616+ });
617+ })
618+ ` ,
619+ errors : [
620+ { messageId : 'noUnnecessaryActTestingLibraryUtil' , line : 8 , column : 15 } ,
621+ ] ,
622+ } ,
623+ {
624+ code : `
625+ import { act } from '@testing-library/react'
626+ import userEvent from '@testing-library/user-event'
627+
628+ test('invalid case', async () => {
629+ const user = userEvent.setup();
630+
631+ act(async () => {
632+ await user.click(element);
633+ });
634+ })
635+ ` ,
636+ errors : [
637+ { messageId : 'noUnnecessaryActTestingLibraryUtil' , line : 8 , column : 9 } ,
638+ ] ,
639+ } ,
569640 {
570641 settings : {
571642 'testing-library/utils-module' : 'test-utils' ,
0 commit comments