class to verify markup is nil; and if it does become a problem you can refactor the markup later.This means 2 things:
Trying to test something at the view layer usually is a symptom of not having confidence in the individual systems that make up your app, and their interplay.
If you’re testing for a particular error message, or that a particular state is rendered from the server, that could be a sign that:
There are legitimate exceptions to this, more on that at the end
This one is slightly controversial; but I find ViewComponents annoying to write tests for, and the results of said tests end up with diminished returns. However, their setup is great when you need those tests. The design of singular instance state, (ideally) simple data structures, and
If you are trying to write tests at the view layer, make sure to keep them focused on specific markup that acts as an indicator & spot check. The reality is that trying to comprehensively assert the completeness and wholistic nature of your view is very onerous & a waste of testing effort. That time would be better spent designing systems are are more easily composable, debuggable. And writing tests at the lower level.