Skip to content

Commit

Permalink
implement suggested change, fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DerTimonius committed Jan 4, 2024
1 parent 28e1b1e commit f528d35
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
36 changes: 18 additions & 18 deletions e2e/__tests__/tsIntegration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ describe('when `Config` type is imported from "@jest/types"', () => {
writeFiles(DIR, {
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
'jest.config.cts': `
/** @type {import('@jest/types').Config} */
const config: Config.InitialOptions = {displayName: 'ts-object-config', verbose: true};
export default config;
import type {Config} from '@jest/types';
const config: Config.InitialOptions = {displayName: 'ts-object-config', verbose: true};
export default config;
`,
'package.json': '{}',
});
Expand All @@ -76,7 +76,7 @@ describe('when `Config` type is imported from "@jest/types"', () => {
writeFiles(DIR, {
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
'jest.config.cts': `
/** @type {import('@jest/types').Config} */
import type {Config} from '@jest/types';
async function getVerbose() {return true;}
export default async (): Promise<Config.InitialOptions> => {
const verbose: Config.InitialOptions['verbose'] = await getVerbose();
Expand Down Expand Up @@ -135,7 +135,7 @@ describe('when `Config` type is imported from "@jest/types"', () => {
writeFiles(DIR, {
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
'jest.config.cts': `
/** @type {import('@jest/types').Config} */
import type {Config} from '@jest/types';
const config: Config.InitialOptions = {testTimeout: '10000'};
export default config;
`,
Expand All @@ -154,7 +154,7 @@ describe('when `Config` type is imported from "@jest/types"', () => {
writeFiles(DIR, {
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
'jest.config.cts': `
/** @type {import('@jest/types').Config} */
import type {Config} from '@jest/types';
const config: Config.InitialOptions = {verbose: true};
export default get config;
`,
Expand Down Expand Up @@ -212,7 +212,7 @@ describe('when `Config` type is imported from "@jest/types"', () => {
writeFiles(DIR, {
'__tests__/dummy.test.js': "test('dummy', () => expect(12).toBe(12));",
'jest.config.cts': `
/** @type {import('@jest/types').Config} */
import type {Config} from '@jest/types';
const config: Config.InitialOptions = {displayName: 'ts-esm-object-config', verbose: true};
export default config;
`,
Expand All @@ -230,7 +230,7 @@ describe('when `Config` type is imported from "@jest/types"', () => {
writeFiles(DIR, {
'__tests__/dummy.test.js': "test('dummy', () => expect(12).toBe(12));",
'jest.config.cts': `
/** @type {import('@jest/types').Config} */
import type {Config} from '@jest/types';
async function getVerbose() {return true;}
export default async (): Promise<Config.InitialOptions> => {
const verbose: Config.InitialOptions['verbose'] = await getVerbose();
Expand Down Expand Up @@ -289,7 +289,7 @@ describe('when `Config` type is imported from "@jest/types"', () => {
writeFiles(DIR, {
'__tests__/dummy.test.js': "test('dummy', () => expect(12).toBe(12));",
'jest.config.cts': `
/** @type {import('@jest/types').Config} */
import type {Config} from '@jest/types';
const config: Config.InitialOptions = {testTimeout: '10000'};
export default config;
`,
Expand All @@ -308,7 +308,7 @@ describe('when `Config` type is imported from "@jest/types"', () => {
writeFiles(DIR, {
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
'jest.config.cts': `
/** @type {import('@jest/types').Config} */
import type {Config} from '@jest/types';
const config: Config.InitialOptions = {verbose: true};
export default get config;
`,
Expand Down Expand Up @@ -368,7 +368,7 @@ describe('when `Config` type is imported from "jest"', () => {
writeFiles(DIR, {
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
'jest.config.cts': `
/** @type {import('@jest/types').Config} */
import type {Config} from 'jest';
const config: Config = {displayName: 'ts-object-config', verbose: true};
export default config;
`,
Expand All @@ -386,7 +386,7 @@ describe('when `Config` type is imported from "jest"', () => {
writeFiles(DIR, {
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
'jest.config.cts': `
/** @type {import('@jest/types').Config} */
import type {Config} from 'jest';
async function getVerbose() {return true;}
export default async (): Promise<Config> => {
const verbose: Config['verbose'] = await getVerbose();
Expand Down Expand Up @@ -445,7 +445,7 @@ describe('when `Config` type is imported from "jest"', () => {
writeFiles(DIR, {
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
'jest.config.cts': `
/** @type {import('@jest/types').Config} */
import type {Config} from 'jest';
const config: Config = {testTimeout: '10000'};
export default config;
`,
Expand All @@ -464,7 +464,7 @@ describe('when `Config` type is imported from "jest"', () => {
writeFiles(DIR, {
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
'jest.config.cts': `
/** @type {import('@jest/types').Config} */
import type {Config} from 'jest';
const config: Config = {verbose: true};
export default get config;
`,
Expand Down Expand Up @@ -522,7 +522,7 @@ describe('when `Config` type is imported from "jest"', () => {
writeFiles(DIR, {
'__tests__/dummy.test.js': "test('dummy', () => expect(12).toBe(12));",
'jest.config.cts': `
/** @type {import('@jest/types').Config} */
import type {Config} from 'jest';
const config: Config = {displayName: 'ts-esm-object-config', verbose: true};
export default config;
`,
Expand All @@ -540,7 +540,7 @@ describe('when `Config` type is imported from "jest"', () => {
writeFiles(DIR, {
'__tests__/dummy.test.js': "test('dummy', () => expect(12).toBe(12));",
'jest.config.cts': `
/** @type {import('@jest/types').Config} */
import type {Config} from 'jest';
async function getVerbose() {return true;}
export default async (): Promise<Config> => {
const verbose: Config['verbose'] = await getVerbose();
Expand Down Expand Up @@ -599,7 +599,7 @@ describe('when `Config` type is imported from "jest"', () => {
writeFiles(DIR, {
'__tests__/dummy.test.js': "test('dummy', () => expect(12).toBe(12));",
'jest.config.cts': `
/** @type {import('@jest/types').Config} */
import type {Config} from 'jest';
const config: Config = {testTimeout: '10000'};
export default config;
`,
Expand All @@ -618,7 +618,7 @@ describe('when `Config` type is imported from "jest"', () => {
writeFiles(DIR, {
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
'jest.config.cts': `
/** @type {import('@jest/types').Config} */
import type {Config} from 'jest';
const config: Config = {verbose: true};
export default get config;
`,
Expand Down
4 changes: 3 additions & 1 deletion packages/jest-config/src/readConfigFileAndSetRootDir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import {
export default async function readConfigFileAndSetRootDir(
configPath: string,
): Promise<Config.InitialOptions> {
const isTS = configPath.endsWith(JEST_CONFIG_EXT_TS || JEST_CONFIG_EXT_CTS);
const isTS =
configPath.endsWith(JEST_CONFIG_EXT_TS) ||
configPath.endsWith(JEST_CONFIG_EXT_CTS);
const isJSON = configPath.endsWith(JEST_CONFIG_EXT_JSON);
let configObject;

Expand Down

0 comments on commit f528d35

Please sign in to comment.