@@ -548,3 +548,61 @@ ruleTester.run('prefer-importing-jest-globals', rule, {
548
548
} ,
549
549
] ,
550
550
} ) ;
551
+
552
+ new RuleTester ( {
553
+ parser : require . resolve ( '@typescript-eslint/parser' ) ,
554
+ } ) . run ( 'prefer-importing-jest-globals: typescript edition' , rule , {
555
+ valid : [ ] ,
556
+ invalid : [
557
+ {
558
+ code : dedent `
559
+ import describe from '@jest/globals';
560
+ describe("suite", () => {
561
+ test("foo");
562
+ expect(true).toBeDefined();
563
+ })
564
+ ` ,
565
+ output : dedent `
566
+ import { describe, expect, test } from '@jest/globals';
567
+ describe("suite", () => {
568
+ test("foo");
569
+ expect(true).toBeDefined();
570
+ })
571
+ ` ,
572
+ parserOptions : { sourceType : 'module' } ,
573
+ errors : [
574
+ {
575
+ endColumn : 7 ,
576
+ column : 3 ,
577
+ line : 3 ,
578
+ messageId : 'preferImportingJestGlobal' ,
579
+ } ,
580
+ ] ,
581
+ } ,
582
+ {
583
+ code : dedent `
584
+ const {describe} = require('@jest/globals');
585
+ describe("suite", () => {
586
+ test("foo");
587
+ expect(true).toBeDefined();
588
+ })
589
+ ` ,
590
+ output : dedent `
591
+ const { describe, expect, test } = require('@jest/globals');
592
+ describe("suite", () => {
593
+ test("foo");
594
+ expect(true).toBeDefined();
595
+ })
596
+ ` ,
597
+ parserOptions : { sourceType : 'script' } ,
598
+ errors : [
599
+ {
600
+ endColumn : 7 ,
601
+ column : 3 ,
602
+ line : 3 ,
603
+ messageId : 'preferImportingJestGlobal' ,
604
+ } ,
605
+ ] ,
606
+ } ,
607
+ ] ,
608
+ } ) ;
0 commit comments