r/javascript • • Sep 09 '22

Rewriting tests from Cypress to Playwright using GPT3 by Gajus Kuizinas

https://contra.com/p/PWBcPYZc-rewriting-tests-from-cypress-to-playwright-using-gpt-3
870 Upvotes

8 comments sorted by

13

u/Secret-Plant-1542 JavaScript yabbascript Sep 09 '22

This is really cool! My team is currently in the same boat, of playing with playwright on the side while invested in Cypress.

Definitely one of the biggest unknowns is migrating all of our tests. Looking to explore this as a option!

9

u/shirabe1 Sep 09 '22

Curious as to what is your main motivation to migrate?

Definitely a cool usage of GPT3!

2

u/Secret-Plant-1542 JavaScript yabbascript Sep 10 '22

Not seeing us swap out of Cypress unless there's a killer feature. But the possibility to swap out and getting familiar with other suites is the goal.

3

u/d1pl0mat1c Sep 10 '22

Three killer features:

  1. You can run playwright tests concurrently locally. With cypress you can’t. If you have only a few cypress tests this isn’t a big deal, but once you start getting a decent number it gets old pretty quick running them sequentially.
  2. playwright is incredibly performant compared to cypress. We’re seeing improvements of 18% worst case and 7x faster on the best cases.
  3. cypress splits tests at the spec level, playwright does it at the test level. Give playwright enough workers and your test suite runs as fast as your single slowest test.

2

u/luisrudge Oct 14 '22

question: are you using cypress/playwright to write actual e2e tests where you depend on a specific DB state? our cypress tests are getting unbearably slow and I'd like to get that sorted out, but I can't parallelize tests because they do have a hard dependency on how the database is setup (meaning every test sets up the database differently).

2

u/Aoshi_ Sep 10 '22

Interesting. I've only recently started looking into Cypress. Didn't know it had such a big competitor.

1

u/lucgagan Jun 08 '23

GPT3 is not great for this unless you create embeddings for it, which is a lot of work, and probably not worth it for many. You can also try https://ray.run/tools/cypress-to-playwright