There are a bunch of different ways to do it. I recommend Jasmine as a test framework. It has a fluent, RSpec-like syntax and is decoupled from its runner enough to run almost everywhere (There are dozens of other frameworks and tools that play nice with it.)?
You can use something like jsdom or one of a number of alternatives to stub out a dom and verify code that runs against it. Those run ridiculously fast on Node.js and are a good first pass for basic correctness. However, you are still going to want to have a few integration tests to make sure that critical things do run in the various browsers.?
You also want to decouple your domain logic from your dom manipulation. This is exactly the same as in any other OO language. The language in your code should be about what the user is trying to accomplish and details about the dom manipulation should be in small composed methods underneath that.? On Fri, Apr 4, 2014 at 2:35 PM, Ian <hobson42@...> wrote:
|