I am new to testing, and am curious how much I should be testing my static HTML/CSS, especially at the beginning of a project, when I know my HTML structure will change often as I figure things out.
Basically, I’ve been writing tests only for my Javascript code. If I start out with static templates, I don’t start testing until I add behavior.
Testing should be a part of any Ember application. It is very easy to get up and going. The best example I can point to is the Ember Starter Kit (https://github.com/emberjs/starter-kit). It has good examples of Integration testing your app.
The article needs updating or perhaps a follow up article with current helpers, ember-testing setup etc.; But I did include a section Testing Strategy which lists my opinions about testing an ember app.
As for testing HTML… When writing integration tests, I like to test the result of my rendered templates. So I may assert / expect some text or css classes are present. However I do not test CSS, except for things like hide/show etc.
My approach to integration testing with Ember is to test for each feature, starting with the simplest thing like a list of links in a menu, then move on to a button that loads more, then perhaps a login form, next the create, edit, delete actions for a web form… and so on. The integration test suite should grow with the set of features. I also like to write the test (failing) then write the feature to pass the test (TDD). However when trying to figure out how Ember works I may just build a part of a feature then once I figure out how the feature is supposed to work in Ember I write a test and continue, etc.
Yes but not slowly, 1st I built a working html/css prototype for the layout and content styles. Then I split up the HTML into handlebars templates using an Ember app starting with the index page and menus.
Since this is a personal project I just worked on little pieces at a time. I started with a general premise that the data setup belongs in the routes; and the behavior and any session data belongs in the controller. For the view layer I prefer to use mostly templates w/ actions that can be handled by controller and also router (events bubble), if needed. And only if necessary, I use a view file, i.e. to specifically handle DOM events or work w/ 3rd party view code (disqus comments). Generally I tried something, wrote tests and if felt right kept the code; and at times when I know what I expect to do I’d write failing tests first. Even just the simple integration tests I wrote give me confidence that everything in the app is playing nice; so I can move on to another feature, then any regression testing is for the most part automated.