jest-expect-message icon indicating copy to clipboard operation
jest-expect-message copied to clipboard

Fix performance problem when wrapping matchers. Fixes #24

Open Coridyn opened this issue 5 years ago • 3 comments

What

Removed the destructuring assignment from inside the wrapMathcers() loop that was significantly slowing down tests when using this library.

Why

Fixes #24 - create and return a single object instead of creating a new object and re-copying all previous properties on every iteration of the loop.

The destructuring code was accidentally quadratic to the number of matcher properties. This changes it back to linear to the number of matchers.

Notes

No functional changes, just quicker :)

Housekeeping

  • [x] Unit tests - no extra tests needed
  • [x] Documentation is up to date - no change to documentation needed
  • [x] No additional lint warnings

Coridyn avatar Jun 23 '20 04:06 Coridyn

Any chance that we can get this merged @mattphillips 🙏 ?

marchaos avatar Feb 02 '21 12:02 marchaos

Any reason this has been delayed in merging?

WORMSS avatar May 21 '21 09:05 WORMSS

Thanks for this PR. I have a relatively large project with a lot of tests. The time to run the tests went down from ~55 seconds to ~35 changes. I copied this PR and merged it to my fork. I'll include it in version 1.1.0 of jest-27-expect-message https://github.com/HumbertoL/jest-expect-message/pull/1

HumbertoL avatar May 18 '22 03:05 HumbertoL

Thanks @Coridyn sorry for the delay in getting this merged!

mattphillips avatar Sep 08 '22 15:09 mattphillips