testing-library / pptr-testing-library

puppeteer + dom-testing-library = 💖
MIT License
287 stars 29 forks source link

Reuse dom-testing-library in same execution context #69

Open andrewiggins opened 2 years ago

andrewiggins commented 2 years ago

Hello! 👋

This PR fixes #1 by only copying dom-testing-library to a puppeteer execution context if it doesn't already exist. This change improves performance significantly in my benchmarks.

base x 22.98 ops/sec ±9.53% (55 runs sampled)
latest x 586 ops/sec ±10.48% (58 runs sampled)
querySelector x 1,102 ops/sec ±12.93% (50 runs sampled)
Fastest is querySelector

It also adds the simple benchmark I used to validate the change improved performance.

Closes #1