Jest-preset-angular: Huge increase in test time since upgraded to jest 24 and new preset

Created on 17 Mar 2019  路  6Comments  路  Source: thymikee/jest-preset-angular

Hi there, we have a medium sized project with around 1600 tests.

We upgraded yesterday to jest 24 with new preset, with recommended migrations changes. We use jsdom 13 as stated in the migration guide.

Please note no change was made to our project. On the same machine, here are the speed reports. It was run with jest alone, and reported result is the second launch of jest command (to ensure no cache problem or something like that).

Before, under jest 23:

Test Suites: 11 skipped, 169 passed, 169 of 180 total
Tests:       82 skipped, 1671 passed, 1753 total
Snapshots:   0 total
Time:        19.142s

After upgrading to new preset 7.0.1 and jest 24:

Test Suites: 11 skipped, 169 passed, 169 of 180 total
Tests:       82 skipped, 1671 passed, 1753 total
Snapshots:   0 total
Time:        29.138s

Attempt with jest 24 and old 6.0.2 preset (no jsdom 13):

Test Suites: 11 skipped, 169 passed, 169 of 180 total
Tests:       82 skipped, 1671 passed, 1753 total
Snapshots:   0 total
Time:        25.061s

Please note it's especially components which encounter that problem. Our most complete component went from 2s testing under jest 23 to more than 8 sec itself alone in jest 24/preset 7.0.2.

Most helpful comment

@blackholegalaxy tests in my project were super slow after upgrade too, but i enabled isolatedModules in ts-jest options and they were back to normal. See this link. It might help you, but it has its costs.

All 6 comments

Hi, this had been addressed in #213. It is the result of switching to use AST transformer + some other things ts-jest 23.10.x does. It's most likely ts-jest issue.

Here is a PR in ts-jest which might speed up the testing once merged. But it probably will stay a bit slower than v6.

From our side the newer version fixes several issues (like coverage accuracy), so we decided to publish it already. If you mostly care about speed, I personally suggest you to stay on v6 for now.

If you can provide a reproduction with an especially slow component, it would enable us to do more performance testing and we could try to speed up the AST transformation done by the preset, provided the slowdown is not caused by ts-jest.

There's nothing this preset can do for you in terms of performance. However expect some speedup in the next minor version of Jest (24.6 or so) as we fixed some regressions.

@blackholegalaxy tests in my project were super slow after upgrade too, but i enabled isolatedModules in ts-jest options and they were back to normal. See this link. It might help you, but it has its costs.

@blackholegalaxy tests in my project were super slow after upgrade too, but i enabled isolatedModules in ts-jest options and they were back to normal. See this link. It might help you, but it has its costs.

This was a huge help! my unit test went from around 13 minutes to just over a minute when ran in my build pipeline on the server.

In our case it didn't change much. 2 seconds average on a 45s run basis. The fact is with jest 24+, we have like... 10 seconds where NOTHING happens. Then tests start normally. Even with test cache enabled.

Was this page helpful?
0 / 5 - 0 ratings