You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While trying to speed up tests for a larger project, I noticed that having to initialize extend-expect for every test adds quite a bit to the overall test run-time. This is about 5-10% for us, but I think it could be bigger for other projects with less overhead.
This would of-course only benefits tests that don't use jest-dom, but at least in our case only about 25% of tests used jest-dom.
Also trying to add jest-dom to a bigger test suite could slow existing tests down and prevent adoption, while lazy-loading could minimize the impact.
A solution would probably depend on importing the matchers with require only when a thin module is already loaded.
This could be added as a separate file to import in setupTests, eg @test-library/jest-dom/lazy
The maintenance cost of this would be having to add every new matcher to the list of matchers in the lazy loader.
I would be happy to contribute this change if this makes sense to the maintainers
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello!
While trying to speed up tests for a larger project, I noticed that having to initialize extend-expect for every test adds quite a bit to the overall test run-time. This is about 5-10% for us, but I think it could be bigger for other projects with less overhead.
This would of-course only benefits tests that don't use jest-dom, but at least in our case only about 25% of tests used jest-dom.
Also trying to add jest-dom to a bigger test suite could slow existing tests down and prevent adoption, while lazy-loading could minimize the impact.
A solution would probably depend on importing the matchers with
require
only when a thin module is already loaded.This could be added as a separate file to import in
setupTests
, eg@test-library/jest-dom/lazy
The maintenance cost of this would be having to add every new matcher to the list of matchers in the lazy loader.
I would be happy to contribute this change if this makes sense to the maintainers
Beta Was this translation helpful? Give feedback.
All reactions