News for hackers. Stuff that matters.
Re:A Primer for Building Single Page Applications with React by philbo on Tuesday March 24, 2015 @08:25AM (#9256119)
The reason I usually prefer to separate script and markup is that it makes the logic easier to test and those tests less brittle when the markup changes. Not having had any experience with react, I was wondering what the accepted approach to testing is?
Re:A Primer for Building Single Page Applications with React by skrebbel on Tuesday March 24, 2015 @08:27AM (#9256129)
React can run without a real DOM attached.

One common way is to have React render into a simulated DOM (e.g. https://github.com/tmpvar/jsdom) and then trigger event handlers with code. You make assertions over the structure of the rendered DOM to know whether things went fine, all without a browser attached.

A dumber way that works remarkably OK too for simpler scenarios is to just have React render stuff to HTML strings and do regexes over those strings. Hacky, and if you're doing serious app development you probably don't want this, but it's a very easy way to get started.