I'm having a hard time grasping the methods I see used to unit test UI functionality for a website (in this case, using ASP.NET MVC3). I tried using Watin, which, in a general sense what I want, with the exception of having to rely an actual instance of a web browser in order to make it work, as it complicates the whole process quite a bit, especially with CI.
In my ideal world this is how I imagine a test working:
- Pass a model to a view, get the output
- Populate a programmatic DOM with the view output
- The test would trigger DOM events to simulate clicking a button, for example, and verify that the DOM was manipulated in the expected way.
I realize this would require both a javascript engine and a DOM implementation either written in .NET or with .NET bindings. Does an obvious solution to my problem exist? If not, is there anything particularly dumb/wrong about the way I'd like to go about it?