@@ -248,16 +248,21 @@ fn check_statements<'a>(
248
248
visited : & mut FxHashSet < Span > ,
249
249
ctx : & LintContext < ' a > ,
250
250
) -> bool {
251
- statements. iter ( ) . any ( |statement| {
252
- if let Statement :: ExpressionStatement ( expr_stmt) = statement {
253
- return check_assert_function_used (
254
- & expr_stmt. expression ,
255
- assert_function_names,
256
- visited,
257
- ctx,
258
- ) ;
251
+ statements. iter ( ) . any ( |statement| match statement {
252
+ Statement :: ExpressionStatement ( expr_stmt) => {
253
+ check_assert_function_used ( & expr_stmt. expression , assert_function_names, visited, ctx)
259
254
}
260
- false
255
+ Statement :: BlockStatement ( block_stmt) => {
256
+ check_statements ( & block_stmt. body , assert_function_names, visited, ctx)
257
+ }
258
+ Statement :: IfStatement ( if_stmt) => {
259
+ if let Statement :: BlockStatement ( block_stmt) = & if_stmt. consequent {
260
+ check_statements ( & block_stmt. body , assert_function_names, visited, ctx)
261
+ } else {
262
+ false
263
+ }
264
+ }
265
+ _ => false ,
261
266
} )
262
267
}
263
268
@@ -287,32 +292,6 @@ fn convert_pattern(pattern: &str) -> CompactStr {
287
292
format ! ( "(?ui)^{pattern}(\\ .|$)" ) . into ( )
288
293
}
289
294
290
- #[ test]
291
- fn debug ( ) {
292
- use crate :: tester:: Tester ;
293
-
294
- let mut pass: Vec < ( & str , Option < serde_json:: Value > ) > = vec ! [ ] ;
295
-
296
- let mut fail = vec ! [ ] ;
297
-
298
- let pass_vitest = vec ! [ (
299
- "
300
- import { test } from 'vitest';
301
- test.skip(\" skipped test\" , () => {})
302
- " ,
303
- None ,
304
- ) ] ;
305
-
306
- let fail_vitest = vec ! [ ] ;
307
-
308
- pass. extend ( pass_vitest) ;
309
- fail. extend ( fail_vitest) ;
310
-
311
- Tester :: new ( ExpectExpect :: NAME , pass, fail)
312
- . with_jest_plugin ( true )
313
- . with_vitest_plugin ( true )
314
- . test ( ) ;
315
- }
316
295
#[ test]
317
296
fn test ( ) {
318
297
use crate :: tester:: Tester ;
@@ -438,6 +417,32 @@ fn test() {
438
417
"# ,
439
418
None ,
440
419
) ,
420
+ (
421
+ r#"
422
+ it("should not warn on await expect", async () => {
423
+ if(true) {
424
+ const asyncFunction = async () => {
425
+ throw new Error('nope')
426
+ };
427
+ await expect(asyncFunction()).rejects.toThrow();
428
+ }
429
+ });
430
+ "# ,
431
+ None ,
432
+ ) ,
433
+ (
434
+ r#"
435
+ it("should not warn on await expect", async () => {
436
+ {
437
+ const asyncFunction = async () => {
438
+ throw new Error('nope')
439
+ };
440
+ await expect(asyncFunction()).rejects.toThrow();
441
+ }
442
+ });
443
+ "# ,
444
+ None ,
445
+ ) ,
441
446
] ;
442
447
443
448
let mut fail = vec ! [
0 commit comments