@@ -322,6 +322,86 @@ ruleTester.run('prefer-importing-jest-globals', rule, {
322322 } ,
323323 ] ,
324324 } ,
325+ {
326+ code : dedent `
327+ const {describe: context} = require('@jest/globals');
328+ context("suite", () => {
329+ test("foo");
330+ expect(true).toBeDefined();
331+ })
332+ ` ,
333+ output : dedent `
334+ const { describe: context, expect, test } = require('@jest/globals');
335+ context("suite", () => {
336+ test("foo");
337+ expect(true).toBeDefined();
338+ })
339+ ` ,
340+ errors : [
341+ {
342+ endColumn : 7 ,
343+ column : 3 ,
344+ line : 3 ,
345+ messageId : 'preferImportingJestGlobal' ,
346+ } ,
347+ ] ,
348+ } ,
349+ {
350+ code : dedent `
351+ const {describe: context} = require('@jest/globals');
352+ describe("something", () => {
353+ context("suite", () => {
354+ test("foo");
355+ expect(true).toBeDefined();
356+ })
357+ })
358+ ` ,
359+ output : dedent `
360+ const { describe, describe: context, expect, test } = require('@jest/globals');
361+ describe("something", () => {
362+ context("suite", () => {
363+ test("foo");
364+ expect(true).toBeDefined();
365+ })
366+ })
367+ ` ,
368+ errors : [
369+ {
370+ endColumn : 9 ,
371+ column : 1 ,
372+ line : 2 ,
373+ messageId : 'preferImportingJestGlobal' ,
374+ } ,
375+ ] ,
376+ } ,
377+ {
378+ code : dedent `
379+ const {describe: []} = require('@jest/globals');
380+ describe("something", () => {
381+ context("suite", () => {
382+ test("foo");
383+ expect(true).toBeDefined();
384+ })
385+ })
386+ ` ,
387+ output : dedent `
388+ const { describe, expect, test } = require('@jest/globals');
389+ describe("something", () => {
390+ context("suite", () => {
391+ test("foo");
392+ expect(true).toBeDefined();
393+ })
394+ })
395+ ` ,
396+ errors : [
397+ {
398+ endColumn : 9 ,
399+ column : 1 ,
400+ line : 2 ,
401+ messageId : 'preferImportingJestGlobal' ,
402+ } ,
403+ ] ,
404+ } ,
325405 {
326406 code : dedent `
327407 const {describe} = require(\`@jest/globals\`);
0 commit comments