Frontend e2e testing with Playwright - waiting for DB

System Information
  • Strapi Version: 4.5.4
  • Operating System: Windows 11 / Ubuntu 22.04
  • Database: MySQL
  • Node Version: 16

Hello to all,

I present you my context:
I want to do some e2e testing with playwright on my frontend written with NextJS.
In order to have testing as close to the real thing as possible, I would like to start Strapi with playwright, so far it works well.
I use a MySQL database in Docker with an initialization dump so that my Strapi contains all my role structure and test data.

The problem I’m having is that the database takes a long time to start and Strapi crashes before starting because the database is not yet available and the connection is denied.
So I have to wait until the database is ready before Strapi starts.
Can I ask Strapi to retry to connect to the database several times until a timeout? Or wait until MySQL is available?

Which approach would you suggest for my problem?

I am open to any suggestion and thank you in advance for your answer.

I wish you all a happy holiday season.

Best regards,

Mariuq

anyone here has tried using Docker volumes to seed the test DB before running Playwright tests? I’ve been running into race conditions and wondering if combining Playwright with test containers or Detox makes things more reliable for frontend E2E with a backend like Strapi. Curious how others are handling this now.