6 ms·
What's weird is it's an untyped string embedded in an HTML template that does things. The API signature is string in magic out. How do I unit test this? How do
by ctvo 3y ago
What's weird is it's an untyped string embedded in an HTML template that does things. The API signature is string in magic out. How do I unit test this? How do we know when someone fat fingered something?
- simonw 3y ago"How do I unit test this?" Playwright should work great for that.
- kodapoda 3y agoYou use Playwright for unit testing? That sounds like an incredibly slow and painful process vs @testing-library.
- Xeamek 3y agoWym? Literally any html attributes/class_names are 'untyped strings that do things'. How is that any different?
- kodapoda 3y agoGP probably means business logic, not setting background color on a div. Coupling HTML with business logic inline reminds me of the good old DHTML. I am really glad the industry moved on from that mess.
- naasking 3y agoBusiness logic must always be executed server-side anyway, so regardless, the client is asking the server "show me the results of this applying business logic". You can do this by having the business logic return a data structure that the client then renders into UI itself, but now you have a state synchronization problem, ie. you have to keep client data structures in sync with server data structures. Alternately, you can use the classic REST pattern: hypermedia as the engine of application state (HATEOAS), and let the server literally tell you what to render, so client state trivially matches server state. This is the htmx way.
- naasking 3y agoDo you have similar objections about untyped strings when setting the "class" attribute? The class attribute also "does things", like change layout, text styling and even behaviour in CSS animations. How do you unit test any dynamic behaviour on HTML pages? There are multiple ways depending on what you want to check.
- naught0 3y agoI mean I use tailwind or a framework like Chakra so yeah, my styling is typed or at the very least has robust editor support
- baq 3y agoYAML IaC roasted to well done levels right here.
- selfmodruntime 3y agoHow we went from code over configuration to YAML hell á la kubernetes and terraform is still beyond me…
- recursivedoubts 3y agohow do you feel about the href attribute in anchor tags?