Skip to content

[Bug]: v29 regression for specifying a tsconfig #3841

@trevor-scheer

Description

@trevor-scheer

Version

v29.x

Steps to reproduce

Baseline, v28

  1. Clone repo: git clone [email protected]:apollo-server-integrations/apollo-server-integration-aws-lambda.git
  2. Install and run tests: npm i && npm t
  3. Note no failures

Errors after upgrading to v29

  1. Checkout reproduction branch: git checkout trevor/jest-v29
  2. Install and run tests: npm i && npm t
  3. Note the following failures:
Expand for error output
  • ts-jest[ts-jest-transformer] (WARN) Define ts-jest config under globals is deprecated. Please do
    transform: {
    <transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],
    },

  • ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting esModuleInterop to true in your TypeScript configuration file (usually tsconfig.json). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information.

  • src/index.ts:78:21 - error TS2550: Property 'fromEntries' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later.

    78 ...Object.fromEntries(headers),
    ~~~~~~~~~~~

Expected behavior

I expect ts-jest to resolve and use the tsconfig that is specified in my Jest config.

Actual behavior

ts-jest does not resolve my specified tsconfig, but instead resolves the default tsconfig.json at the root of the project.

Debug log

Available on request (or can be generated through the reproduction). It is too long to submit the issue.

Additional context

Problem

The errors are a bit cryptic, but I've deduced that ts-jest is no longer resolving the specified tsconfig file in the jest config (below). It is instead always falling back to the default tsconfig.json.

I've also tried updating to the transform configuration format with the same result.

Confirmation steps

  1. Rename the top level tsconfig: mv tsconfig.json _tsconfig.json
  2. Rename the test-specific tsconfig: mv tsconfig.test.json tsconfig.json
  3. Run the tests: npm t
  4. Note no errors

Jest config

import type { Config } from '@jest/types';

const config: Config.InitialOptions = {
  preset: 'ts-jest',
  testEnvironment: 'node',
  roots: ['src'],
  globals: {
    'ts-jest': {
      tsconfig: 'tsconfig.test.json',
    },
  },
  testRegex: '/__tests__/.*.test.ts$',
  verbose: true,
  snapshotFormat: { escapeString: false, printBasicPrototype: false },
};

export default config;

Environment

System:
    OS: macOS 12.3.1
    CPU: (8) arm64 Apple M1
  Binaries:
    Node: 16.17.0 - ~/Desktop/ApolloRepos/apollo-server-integration-aws-lambda/.volta/tools/image/node/16.17.0/bin/node
    npm: 8.18.0 - ~/Desktop/ApolloRepos/apollo-server-integration-aws-lambda/.volta/tools/image/npm/8.18.0/bin/npm
  npmPackages:
    jest: 29.0.0 => 29.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions