Is there any consensus on the most effective way t...
# http4k
a
Is there any consensus on the most effective way to perform SSR testing nowadays? • approval tests verify the exact outputted HTML, but can't test form submissions • webdriver tests are slower, more finicky, flakey, but can test form submissions Is the answer a bit of both?
s
A bit of both is what I’ve done in the past
👍 1
c
All my forms have a DTO (FormDTO) to back them. I currently have an internal library to take a form submission (www-form-urlencoded) and use kotlinx.serialization type coercion + a little naming scheme (e.g.
.user.permission[3]
for the HTML input name attributes) so I can do structured data in forms. I'm interested to make this library a real citizen of kotlinx.serialization so I can both serialize and deserialize between my FormDTOs and their www-form-urlencoded representation. This would make testing form submissions a bit nicer. Since I use the formDTO to set the HTML input name attributes, those always fit the backing FormDTO.
g
Playwright is the more modern equivalent of webdriver. Yes, they are going to be slower but they don't have to be flakey. Headless mode is usually a bit quicker but will probably still feel a bit slow. The problem with http4k being so nice to test is that we get spoiled! 🤣
😁 1
a
What makes playwright more modern/better? I'm unsure if either implies there's a headless browser involved.
g
Well, Playwright was certainly written more recently, so I'm going to tick the "more modern" box. Is it better... I guess, like all things, it depends. There are some core differences; the way the tests fan out to multiple browsers, the communication protocol between driver and browser, the API and how async actions are handled in the codebase. For me, unless I have very specific needs for what Webdriver is better at, I'm picking Playwright these days. YMMV. • To be clear, Webdriver itself is a protocol, but I'm using it interchangeably with the standard implementation. (Selenium) as I assume that's what you meant.
a
For the http4k modules, it seems to me like: • playwright delegates DOM rendering to whatever playwright driver you choose. • webdriver uses jsoup So unless playwright has a jsoup driver, webdriver is probably going to be faster and more portable