Does vitest have the same problem as jest in this regard? #1665
Unanswered
spicylemonhaha
asked this question in
Q&A
Replies: 1 comment 7 replies
-
|
Yes, Vitest loads every imported module. It won't load a module, if imported variable is not used tho, which is a rare case and usually handled by linters. I don't think tree-shaking is possible with Node.js context tho, we would need to bundle code for each test file. |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When we analysed our customer’s tests, we soon noticed a recurring problem: that the most significant impact on performance was the number of modules which needed to be imported by the tests in question. Jest creates a new module registry for each test file and has to crawl through the whole dependency chain of modules which are imported by the test suite, even if they are completely unused. It is easy for developers to overlook this fact given that build tools such as webpack can eliminate dead code via tree-shaking, but this is only the case for production builds and does not help with test execution or development servers.
https://blog.codecentric.de/en/2021/11/javascript-test-performance-getting-the-best-out-of-jest/
Beta Was this translation helpful? Give feedback.
All reactions