Search code examples
djangotestingfrontendbackend

Combine django tests and testcafe?


I'm experminenting testing of frontend with testcafe https://testcafe.io/documentation/402631/guides/overview/why-testcafe and backend with django https://docs.djangoproject.com/en/5.0/topics/testing/overview/#running-tests

If I start two separate shell:

 python ./manage.py test #backend

 testcafe chromium ./tests/testcafe.js  #frontend

The backend test run faster than the frontend. I'd like to use the django test feature that create an empty database for each execution. And django tests for backend, is there a way to make a combo of those?


Solution

  • Django's test command is meant for running unit tests not integration tests.

    If you want to easily setup a test server with an empty database Django has a testserver command for that purpose. This command also allows you to load some data into the test database that is created using fixtures. So you can start a testserver by running:

    python ./manage.py testserver