Replies: 4 comments 1 reply
-
That is framework dependent, for Django/Python, I use from django_htmx.middleware import HtmxDetails
def htmx_request(user=None,
get_url=None,
post_url=None,
post_data={},
trigger=None,
**kwargs):
headers = dict(HTTP_HX_Request="true", HTTP_HX_Trigger_Name=trigger)
if get_url is not None:
request = RequestFactory().get(
get_url, {x: y for x, y in kwargs.items() if y is not None}, **headers)
if post_url is not None:
kwargs.update(headers)
request = RequestFactory().post(post_url, data=post_data, **kwargs)
request.htmx = HtmxDetails(request)
request.user = user if user else AnonymousUser()
return request |
Beta Was this translation helpful? Give feedback.
-
Every professional framework has at least one chapter in his docs about how to write tests. I think there are three ways:
This is just a gentle reminder that a chapter in the docs would be useful. |
Beta Was this translation helpful? Give feedback.
-
Seconded. I just came here to ask this. I had been thinking of using Selenium/Playwright/Puppeteer but had a discussion with someone recently where they had a bad experience with e2e due to fragile tests and just pushed all testing to the unit test level. This vibes with my intuition. My backend is in Go so it's likely possible to do something similar to what @BoPeng does in Python but how are people testing their HTMX applications in general? |
Beta Was this translation helpful? Give feedback.
-
I personally use Playwright that was already mentioned above, but there's indeed no "offical" way to test htmx-based apps for now. Btw see #2360 for a related discussion on race-conditions and how to make reliable htmx-based tests. If someone feels like it, PRs improving documentation are always welcome! |
Beta Was this translation helpful? Give feedback.
-
There is a question on Stackoverflow about how to test htmx based applications.
I think there should be a small section about this in the docs.
Beta Was this translation helpful? Give feedback.
All reactions