Ts-jest: RFC: Performance after upgrading from 25.2.1 to 25.3.0

Created on 30 Mar 2020  路  22Comments  路  Source: kulshekhar/ts-jest

Issue :

25.3.0 version is extremely slow compared to 25.2.x.
E.g. my previous test runs were 17s, and 135s after update.

Regression

Most helpful comment

Maybe it's related but moving to 25.3.0, it seems that a lot more files are getting compiled. We use this in a rails project and are now getting a bunch of errors like error TS5055: Cannot write file '/<<path>>/config/webpack/development.js' because it would overwrite input file. which suggests it now handles every js file in repository.

All 22 comments

can you please provide more information ? Do you run with or without cache ? Did you clear cache after upgrading to 25.3.0 ?

I tried to run jest with --clearCache, did not help.

from what I can see is, before upgrading probably your tests ran with cache. After upgrading, old cache becomes invalid so tests will need to cache again. That's why you saw a big difference. Several steps that you can help us to verify is:

  • Clear cache
  • Run tests with --no-cache for 25.2.1
  • Clear cache again
  • Run tests with --no-cache for 25.3.0

If the amount of time tests take is the same for these above steps, it means no downgrade

Thank you for the suggestion, but it did not help as well :(
After all steps and running with no-cache it takes ~270s to finish.

Hmm I don鈥檛 see any issues on my side. Also confirmed from https://github.com/kulshekhar/ts-jest/pull/1450#issuecomment-605885686

Any chances to have your repo to try out ?

Unfortunately no.
We have pinned version for now. Maybe someone else will face this issue too.

Maybe it's related but moving to 25.3.0, it seems that a lot more files are getting compiled. We use this in a rails project and are now getting a bunch of errors like error TS5055: Cannot write file '/<<path>>/config/webpack/development.js' because it would overwrite input file. which suggests it now handles every js file in repository.

Maybe it's related but moving to 25.3.0, it seems that a lot more files are getting compiled. We use this in a rails project and are now getting a bunch of errors like error TS5055: Cannot write file '/<<path>>/config/webpack/development.js' because it would overwrite input file. which suggests it now handles every js file in repository.

thanks for your feedback. Do you use allowJs in your repo ?

yes, I do. After checking the other issues, I think #1472 will probably resolve the error for me.

Thanks. Probably the issue is bigger than just the fix #1472 as you mentioned that there are more files getting compile. That is a useful hint to solve this issue.

Up til now, imo #1472 is just a workaround and there should be a proper fix.

I want to add that we are using allowJs too, without it compilation fails for 25.3.0, but works for 25.2.1

if you guys don't mind, please test with this tgz file. I just made an attempt to fix it but not so sure.

I'm hitting the same problem just after the upgrade to 25.3.0 and I have a lot of:
Cannot write file 'path/to/file.js' because it would overwrite input file

I'm using allowJs too. Also if I add the outDir tests will work but they are extremely slow.

hi guys, please test again this branch https://github.com/ahnpnl/ts-jest/tree/fix-diagnostics to see if it helps

Seems like I cannot install it from GitHub with yarn add --dev -W https://github.com/ahnpnl/ts-jest#fix-diagnostics. Here is the error:

$ npm run build
npm WARN lifecycle The node binary used for scripts is /var/folders/sl/w6pt8g5j2b332rk_776pwdbc0000gn/T/yarn--1585747708265-0.824303838895643/node but npm is using /Users/occhipintia/.nvm/versions/node/v10.13.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> [email protected] prebuild /Users/occhipintia/Library/Caches/Yarn/v6/.tmp/5c55e78258b66b7b689625fcb8d6906e.dd8b2e4e117869706228fab75b0ba68f183752f0.prepare
> node scripts/clean-dist.js


> [email protected] build /Users/occhipintia/Library/Caches/Yarn/v6/.tmp/5c55e78258b66b7b689625fcb8d6906e.dd8b2e4e117869706228fab75b0ba68f183752f0.prepare
> tsc -p tsconfig.build.json

src/cli/config/migrate.ts:3:32 - error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.

3 import * as stringifyJson from 'fast-json-stable-stringify'
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

NOTE: I'm in a monorepo.

Here is the zip of the tgz file.
ts-jest-25.3.1.tgz.zip

Alright, seems like we have some good news: installed the new version from your zip I can run the tests without the Cannot write file 'path/to/file.js' because it would overwrite input file error.

Also I have notice the slowness just the first time I run it, but the second run, using the cache, it goes down to 5 seconds running all tests. So I can say the last fix solved the problem. Looking forward for the 25.3.1 release!

It is also worth to say that I haven't changed my tsconfig.json to make this work again.

Thanks for your time @ahnpnl!

thanks a lot for helping us !. I will make a PR shortly 馃憤

@ahnpnl, thanks a lot for the fix! Do you know when it will be released?

we are having a bit issue with publishing today, but will be solved shortly. Stay tune :)

Updated: 25.3.1 is out

Yes, we also experienced perf degradation. Will test with 25.3.1

Was this page helpful?
0 / 5 - 0 ratings