Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading from 25.3.1 to 25.4.0 breaks monorepo projects #1613

Closed
czyzby opened this issue May 8, 2020 · 20 comments · Fixed by #1614
Closed

Upgrading from 25.3.1 to 25.4.0 breaks monorepo projects #1613

czyzby opened this issue May 8, 2020 · 20 comments · Fixed by #1614
Labels
🐛 Bug Confirmed Bug is confirmed

Comments

@czyzby
Copy link

czyzby commented May 8, 2020

🐛 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
@czyzby czyzby added Bug Report Needs Repo Need a minimium repository to reproduce the problem Needs Triage labels May 8, 2020
@ahnpnl
Copy link
Collaborator

ahnpnl commented May 8, 2020

would you please try 25.5.1-alpha.0 by install ts-jest@next ?

@czyzby
Copy link
Author

czyzby commented May 8, 2020

Same issue, shared project is not correctly resolved.

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 8, 2020

Hmm ok so it’s a different issue with 25.5.1 trying to solve. Would you please provide a minimum repo ? That will be faster for debugging

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 8, 2020

in 25.5.0 we added a partial support for TypeScript projectReferences. From the log I can see it goes into the path of trying to resolve file because the monorepo uses projectReferences.

Can you please try to run tsc -b, clear jest cache and rerun test ? I'm curious

@czyzby
Copy link
Author

czyzby commented May 8, 2020

I'll try to provide a minimal example.

@czyzby czyzby closed this as completed May 8, 2020
@czyzby czyzby reopened this May 8, 2020
@czyzby
Copy link
Author

czyzby commented May 8, 2020

I did clear the cache, removed node_modules, etc. Only reverting to 25.3 helped so far.

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 8, 2020

did you run tsc -b before running tests ?

@czyzby
Copy link
Author

czyzby commented May 8, 2020

I didn't, and I never had to before. Can confirm that tsc -b generates index.js in the directory that ts-jest expect it to be, but I'd rather not have to run tsc -b on the shared module each time before running the tests.

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 8, 2020

ok, I will add an option to ts-jest to disable/enable support projectReferences and publish it into 25.5.1-alpha.1 , would you please help to test once it's published ?

@ahnpnl ahnpnl added 🐛 Bug and removed Bug Report Needs Repo Need a minimium repository to reproduce the problem Needs Triage labels May 8, 2020
@czyzby
Copy link
Author

czyzby commented May 8, 2020

See this repo. master branch passes with 25.3, while reproduction branch fails with 25.5 even though tests were not modified. This is the failing CI build.

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 8, 2020

here is the fix for your issue https://drive.google.com/open?id=17p2-uk8Z26k0qd8NGhhtE7KOz3wntcLZ I have cloned your repo and test this fix against reproduction branch and it worked for me. Would you please check to confirm ?

@czyzby
Copy link
Author

czyzby commented May 8, 2020

I'll be able to test it in a few hours, but I'd assume it's OK. I'll give you pushing rights to the repository, you can test it against the CI.

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 8, 2020

that is great !

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 8, 2020

anyways, e2e tests already covered it :)

@czyzby
Copy link
Author

czyzby commented May 8, 2020

I can confirm that the fixed version you uploaded passes the CI tests.

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 8, 2020

Nice, the fix will be in 25.5.1 Thanks for your confirmation.

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 9, 2020

close via #1614

@ahnpnl ahnpnl closed this as completed May 9, 2020
@ahnpnl
Copy link
Collaborator

ahnpnl commented May 9, 2020

25.5.1 is out

@czyzby
Copy link
Author

czyzby commented May 9, 2020

Thanks, the tests pass as expected without tsc -b when using 25.5.1. Can I remove the reproduction repository now @ahnpnl?

@ahnpnl
Copy link
Collaborator

ahnpnl commented May 9, 2020

sure 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Confirmed Bug is confirmed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants