@@ -22,6 +22,16 @@ ruleTester.run('prefer-importing-jest-globals', rule, {
22
22
` ,
23
23
parserOptions : { sourceType : 'module' } ,
24
24
} ,
25
+ {
26
+ code : dedent `
27
+ // with import
28
+ import { 'test' as test, expect } from '@jest/globals';
29
+ test('should pass', () => {
30
+ expect(true).toBeDefined();
31
+ });
32
+ ` ,
33
+ parserOptions : { sourceType : 'module' , ecmaVersion : 2022 } ,
34
+ } ,
25
35
{
26
36
code : dedent `
27
37
test('should pass', () => {
@@ -65,6 +75,13 @@ ruleTester.run('prefer-importing-jest-globals', rule, {
65
75
` ,
66
76
parserOptions : { sourceType : 'module' } ,
67
77
} ,
78
+ {
79
+ code : dedent `
80
+ import { 'it' as itChecks } from '@jest/globals';
81
+ itChecks("foo");
82
+ ` ,
83
+ parserOptions : { sourceType : 'module' , ecmaVersion : 2022 } ,
84
+ } ,
68
85
{
69
86
code : dedent `
70
87
const { test } = require('@jest/globals');
@@ -158,6 +175,56 @@ ruleTester.run('prefer-importing-jest-globals', rule, {
158
175
} ,
159
176
] ,
160
177
} ,
178
+ {
179
+ code : dedent `
180
+ import { 'describe' as describe } from '@jest/globals';
181
+ describe("suite", () => {
182
+ test("foo");
183
+ expect(true).toBeDefined();
184
+ })
185
+ ` ,
186
+ output : dedent `
187
+ import { 'describe' as describe, expect, test } from '@jest/globals';
188
+ describe("suite", () => {
189
+ test("foo");
190
+ expect(true).toBeDefined();
191
+ })
192
+ ` ,
193
+ parserOptions : { sourceType : 'module' , ecmaVersion : 2022 } ,
194
+ errors : [
195
+ {
196
+ endColumn : 7 ,
197
+ column : 3 ,
198
+ line : 3 ,
199
+ messageId : 'preferImportingJestGlobal' ,
200
+ } ,
201
+ ] ,
202
+ } ,
203
+ {
204
+ code : dedent `
205
+ import { 'describe' as context } from '@jest/globals';
206
+ context("suite", () => {
207
+ test("foo");
208
+ expect(true).toBeDefined();
209
+ })
210
+ ` ,
211
+ output : dedent `
212
+ import { 'describe' as context, expect, test } from '@jest/globals';
213
+ context("suite", () => {
214
+ test("foo");
215
+ expect(true).toBeDefined();
216
+ })
217
+ ` ,
218
+ parserOptions : { sourceType : 'module' , ecmaVersion : 2022 } ,
219
+ errors : [
220
+ {
221
+ endColumn : 7 ,
222
+ column : 3 ,
223
+ line : 3 ,
224
+ messageId : 'preferImportingJestGlobal' ,
225
+ } ,
226
+ ] ,
227
+ } ,
161
228
{
162
229
code : dedent `
163
230
jest.useFakeTimers();
0 commit comments