Does anyone have a #wagtail trick for speeding up #playwright tests? Seems like the schema flush operation is taking several seconds each test (because of the transaction database set up and clean up). I was considering creating a replacement app that defines some type of replacement migration.

@CodenameTim I don't have one for you. But I've reposted your question in a couple spots that might lead us to someone that does.

I have honestly never used Playwright. What sort of tests are you running with it? Functional browser tests?

@vossisboss yes, I have a page that involves some javascript code. I have a playwright test that validates it.

@CodenameTim I got a lead for you but I'm not 100% how useful it will be for your use case. Alex Morega shared a Playwright example he created for his Wagtail Space talk here: https://github.com/mgax/ws25-code-creates-content/blob/main/home/tests/test_browser.py

He also said:

Run tests with --reuse-db (pytest) or --keepdb (Django's test runner). This way, the schema will not be flushed, just the data.

Recreate select records that Wagtail creates during migrations: locale, site, root page, collection.

ws25-code-creates-content/home/tests/test_browser.py at main · mgax/ws25-code-creates-content

Companion repository for my Wagtail Space 2025 talk - mgax/ws25-code-creates-content

GitHub
@CodenameTim Also @zerolab said "We're using Behave with overridden test runners that use DSLR to take a snapshot after the initial db setup, and restore it on tear down, which is a lot faster than resetting db/re-running migrations" Example here: https://github.com/ONSdigital/dis-wagtail/blob/main/functional_tests/behave_fixtures.py
stupid-django-tricks/clone_db_testcase/README.md at master · shangxiao/stupid-django-tricks

Contribute to shangxiao/stupid-django-tricks development by creating an account on GitHub.

GitHub
@SebCorbin looks promising! Thank you