Anyone using Django with HTMX? How are you writing UI tests for HTMX behaviour? The standard Django tests don't run JavaScript so what do you use for this and how is the performance?
That's the fun part. It's just HTML attributes, so you can test them without a full browser and JS engine. Just parse the HTML. Tests are super fast and never flaky.
But how are you checking that e.g. on submit the HTMX replaced the correct selector inside another form and that on submitting that form HTMX uses a HX-Redirect header to send you to the right page? If you're not testing that, don't you get cases of tests passing when the UI is actually broken in the browser?
We can use playwright for these type of tests and still stay almost entirely in Python.
Just submit a request, capture the response, and test it for whatever you like. Django has a test HTTP client that lets you craft whatever request you like, submit it, and captures the response. Once you have the response it's trivial to check its HTML content and its headers.
Are you looking for something like Playwright or Cypress for end-to-end testing?
As close to end-to-end as practical. Playwright seems a lot heavier than standard Django tests.