Skip to content

Commit f528d35

Browse files
committed
implement suggested change, fix tests
1 parent 28e1b1e commit f528d35

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

e2e/__tests__/tsIntegration.test.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ describe('when `Config` type is imported from "@jest/types"', () => {
5858
writeFiles(DIR, {
5959
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
6060
'jest.config.cts': `
61-
/** @type {import('@jest/types').Config} */
62-
const config: Config.InitialOptions = {displayName: 'ts-object-config', verbose: true};
63-
export default config;
61+
import type {Config} from '@jest/types';
62+
const config: Config.InitialOptions = {displayName: 'ts-object-config', verbose: true};
63+
export default config;
6464
`,
6565
'package.json': '{}',
6666
});
@@ -76,7 +76,7 @@ describe('when `Config` type is imported from "@jest/types"', () => {
7676
writeFiles(DIR, {
7777
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
7878
'jest.config.cts': `
79-
/** @type {import('@jest/types').Config} */
79+
import type {Config} from '@jest/types';
8080
async function getVerbose() {return true;}
8181
export default async (): Promise<Config.InitialOptions> => {
8282
const verbose: Config.InitialOptions['verbose'] = await getVerbose();
@@ -135,7 +135,7 @@ describe('when `Config` type is imported from "@jest/types"', () => {
135135
writeFiles(DIR, {
136136
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
137137
'jest.config.cts': `
138-
/** @type {import('@jest/types').Config} */
138+
import type {Config} from '@jest/types';
139139
const config: Config.InitialOptions = {testTimeout: '10000'};
140140
export default config;
141141
`,
@@ -154,7 +154,7 @@ describe('when `Config` type is imported from "@jest/types"', () => {
154154
writeFiles(DIR, {
155155
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
156156
'jest.config.cts': `
157-
/** @type {import('@jest/types').Config} */
157+
import type {Config} from '@jest/types';
158158
const config: Config.InitialOptions = {verbose: true};
159159
export default get config;
160160
`,
@@ -212,7 +212,7 @@ describe('when `Config` type is imported from "@jest/types"', () => {
212212
writeFiles(DIR, {
213213
'__tests__/dummy.test.js': "test('dummy', () => expect(12).toBe(12));",
214214
'jest.config.cts': `
215-
/** @type {import('@jest/types').Config} */
215+
import type {Config} from '@jest/types';
216216
const config: Config.InitialOptions = {displayName: 'ts-esm-object-config', verbose: true};
217217
export default config;
218218
`,
@@ -230,7 +230,7 @@ describe('when `Config` type is imported from "@jest/types"', () => {
230230
writeFiles(DIR, {
231231
'__tests__/dummy.test.js': "test('dummy', () => expect(12).toBe(12));",
232232
'jest.config.cts': `
233-
/** @type {import('@jest/types').Config} */
233+
import type {Config} from '@jest/types';
234234
async function getVerbose() {return true;}
235235
export default async (): Promise<Config.InitialOptions> => {
236236
const verbose: Config.InitialOptions['verbose'] = await getVerbose();
@@ -289,7 +289,7 @@ describe('when `Config` type is imported from "@jest/types"', () => {
289289
writeFiles(DIR, {
290290
'__tests__/dummy.test.js': "test('dummy', () => expect(12).toBe(12));",
291291
'jest.config.cts': `
292-
/** @type {import('@jest/types').Config} */
292+
import type {Config} from '@jest/types';
293293
const config: Config.InitialOptions = {testTimeout: '10000'};
294294
export default config;
295295
`,
@@ -308,7 +308,7 @@ describe('when `Config` type is imported from "@jest/types"', () => {
308308
writeFiles(DIR, {
309309
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
310310
'jest.config.cts': `
311-
/** @type {import('@jest/types').Config} */
311+
import type {Config} from '@jest/types';
312312
const config: Config.InitialOptions = {verbose: true};
313313
export default get config;
314314
`,
@@ -368,7 +368,7 @@ describe('when `Config` type is imported from "jest"', () => {
368368
writeFiles(DIR, {
369369
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
370370
'jest.config.cts': `
371-
/** @type {import('@jest/types').Config} */
371+
import type {Config} from 'jest';
372372
const config: Config = {displayName: 'ts-object-config', verbose: true};
373373
export default config;
374374
`,
@@ -386,7 +386,7 @@ describe('when `Config` type is imported from "jest"', () => {
386386
writeFiles(DIR, {
387387
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
388388
'jest.config.cts': `
389-
/** @type {import('@jest/types').Config} */
389+
import type {Config} from 'jest';
390390
async function getVerbose() {return true;}
391391
export default async (): Promise<Config> => {
392392
const verbose: Config['verbose'] = await getVerbose();
@@ -445,7 +445,7 @@ describe('when `Config` type is imported from "jest"', () => {
445445
writeFiles(DIR, {
446446
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
447447
'jest.config.cts': `
448-
/** @type {import('@jest/types').Config} */
448+
import type {Config} from 'jest';
449449
const config: Config = {testTimeout: '10000'};
450450
export default config;
451451
`,
@@ -464,7 +464,7 @@ describe('when `Config` type is imported from "jest"', () => {
464464
writeFiles(DIR, {
465465
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
466466
'jest.config.cts': `
467-
/** @type {import('@jest/types').Config} */
467+
import type {Config} from 'jest';
468468
const config: Config = {verbose: true};
469469
export default get config;
470470
`,
@@ -522,7 +522,7 @@ describe('when `Config` type is imported from "jest"', () => {
522522
writeFiles(DIR, {
523523
'__tests__/dummy.test.js': "test('dummy', () => expect(12).toBe(12));",
524524
'jest.config.cts': `
525-
/** @type {import('@jest/types').Config} */
525+
import type {Config} from 'jest';
526526
const config: Config = {displayName: 'ts-esm-object-config', verbose: true};
527527
export default config;
528528
`,
@@ -540,7 +540,7 @@ describe('when `Config` type is imported from "jest"', () => {
540540
writeFiles(DIR, {
541541
'__tests__/dummy.test.js': "test('dummy', () => expect(12).toBe(12));",
542542
'jest.config.cts': `
543-
/** @type {import('@jest/types').Config} */
543+
import type {Config} from 'jest';
544544
async function getVerbose() {return true;}
545545
export default async (): Promise<Config> => {
546546
const verbose: Config['verbose'] = await getVerbose();
@@ -599,7 +599,7 @@ describe('when `Config` type is imported from "jest"', () => {
599599
writeFiles(DIR, {
600600
'__tests__/dummy.test.js': "test('dummy', () => expect(12).toBe(12));",
601601
'jest.config.cts': `
602-
/** @type {import('@jest/types').Config} */
602+
import type {Config} from 'jest';
603603
const config: Config = {testTimeout: '10000'};
604604
export default config;
605605
`,
@@ -618,7 +618,7 @@ describe('when `Config` type is imported from "jest"', () => {
618618
writeFiles(DIR, {
619619
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
620620
'jest.config.cts': `
621-
/** @type {import('@jest/types').Config} */
621+
import type {Config} from 'jest';
622622
const config: Config = {verbose: true};
623623
export default get config;
624624
`,

packages/jest-config/src/readConfigFileAndSetRootDir.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ import {
2727
export default async function readConfigFileAndSetRootDir(
2828
configPath: string,
2929
): Promise<Config.InitialOptions> {
30-
const isTS = configPath.endsWith(JEST_CONFIG_EXT_TS || JEST_CONFIG_EXT_CTS);
30+
const isTS =
31+
configPath.endsWith(JEST_CONFIG_EXT_TS) ||
32+
configPath.endsWith(JEST_CONFIG_EXT_CTS);
3133
const isJSON = configPath.endsWith(JEST_CONFIG_EXT_JSON);
3234
let configObject;
3335

0 commit comments

Comments
 (0)