@@ -1092,23 +1092,29 @@ impl AnyJsExpression {
10921092 false
10931093 }
10941094
1095- /// Checks whether the current function call is:
1096- /// - `it`: many libraries such as Node.js, Mocha, Jest, etc.
1097- /// - `test`: many libraries such as Node.js, bun, etc.
1095+ /// Checks whether the current function call is a test body context:
1096+ /// - `it` and `test` calls accepted by [`contains_a_test_pattern`], such as
1097+ /// `it.only` or `test.concurrent`
1098+ /// - `it.each` and `test.each` table test calls accepted by
1099+ /// [`contains_a_test_each_pattern`], such as `test.concurrent.each`
10981100 /// - [`Deno.test`](https://docs.deno.com/runtime/manual/basics/testing/)
10991101 /// - [`waitFor`](https://testing-library.com/docs/dom-testing-library/api-async/#waitfor)
1102+ ///
1103+ /// [`contains_a_test_pattern`]: crate::AnyJsExpression::contains_a_test_pattern
1104+ /// [`contains_a_test_each_pattern`]: crate::AnyJsExpression::contains_a_test_each_pattern
11001105 pub fn contains_it_call ( & self ) -> bool {
1101- let mut members = CalleeNamesIterator :: new ( self . clone ( ) ) ;
1102-
1103- let texts: [ Option < TokenText > ; 2 ] = [ members. next ( ) , members. next ( ) ] ;
1106+ let members = CalleeNamesIterator :: new ( self . clone ( ) ) . collect :: < Vec < _ > > ( ) ;
11041107
1105- let mut rev = texts . iter ( ) . rev ( ) . flatten ( ) ;
1108+ let mut rev = members . iter ( ) . rev ( ) ;
11061109
11071110 let first = rev. next ( ) . map ( |t| t. text ( ) ) ;
11081111 let second = rev. next ( ) . map ( |t| t. text ( ) ) ;
11091112
11101113 match first {
1111- Some ( "test" | "it" | "waitFor" ) => true ,
1114+ Some ( "test" | "it" ) => {
1115+ self . contains_a_test_pattern ( ) || self . contains_a_test_each_pattern ( )
1116+ }
1117+ Some ( "waitFor" ) => true ,
11121118 Some ( "Deno" ) => matches ! ( second, Some ( "test" ) ) ,
11131119 _ => false ,
11141120 }
0 commit comments