Skip to content

Upgrading from 25.3.1 to 25.4.0 breaks monorepo projects #1613

@czyzby

Description

@czyzby

🐛 Bug Report

I have a TypeScript project using Yarn workspaces and TypeScript project references. I have a single shared project used by my backend and frontend projects. As expected, some tests in both backend and frontend projects rely on classes and functions exported from the shared project.

When using 25.3.1 version, I can run the tests without any issues. Shared code is correctly imported.

After updating to 25.4.0 or 25.5.0, I run into the following issue:

FAIL backend <TEST NAME>.test.ts
  ● Test suite failed to run

    File not found: /PATH/TO/PROJECT/packages/shared/dist/index.js (resolved as: /PATH/TO/PROJECT/packages/shared/dist/index.js)

      at ConfigSet.resolvePath (../../node_modules/ts-jest/dist/config/config-set.js:697:19)
      at Object.getCompileResultFromReferencedProject (../../node_modules/ts-jest/dist/compiler/compiler-utils.js:122:38)
      at compileFn (../../node_modules/ts-jest/dist/compiler/language-service.js:126:41)
      at Object.compile (../../node_modules/ts-jest/dist/compiler/instance.js:52:21)
      at TsJestTransformer.process (../../node_modules/ts-jest/dist/ts-jest-transformer.js:85:41)
      at ScriptTransformer.transformSource (../../node_modules/@jest/transform/build/ScriptTransformer.js:481:35)
      at ScriptTransformer._transformAndBuildScript (../../node_modules/@jest/transform/build/ScriptTransformer.js:586:40)
      at ScriptTransformer.transform (../../node_modules/@jest/transform/build/ScriptTransformer.js:624:25)

It seems that the shared project cannot be correctly resolved.

To Reproduce

Steps to reproduce the behavior:

  • Setup a TypeScript Yarn project with workspaces and project references.
  • Set one project as a dependency of the other.
  • Write a test that references the imported project.

See https://github.com/czyzby/ts-node-1613-reproduction.

Expected behavior

  • Tests should pass and dependency project should be correctly resolved.

envinfo

System:
    OS: Linux Mint 19.3

Npm packages:
    jest: 25.1.0
    ts-jest: 25.4.0
    typescript: 3.8.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions