+1 for Javascript testing in general, though I don't think that our JS code in its current state is well-written for tests - it's too much a bundle of interconnected DOM logic to be easily split up into unit tests.<div>
<br></div><div>Also, while I'm a big fan of mocha for nodejs tests, I'm skeptical of its browser support - it seems to fail entirely in IE, which is kind of the point of browser testing for me. Is this just me making a mistake? Jasmine has fared better in multiple browsers afaik.<br>
<br><div class="gmail_quote">On Wed, Sep 12, 2012 at 11:05 PM, John Firebaugh <span dir="ltr"><<a href="mailto:john.firebaugh@gmail.com" target="_blank">john.firebaugh@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I was the contributor who suggested introducing Capybara-based integration tests. I've used them in the past and found them very helpful. It's possible to use Capybara without Selenium, but I've found that most often I needed a driver that supports JavaScript, and I needed to be able to see and interact with the page when something goes wrong, which was a disadvantage with headless drivers. It sounds like the consensus is to avoid Selenium at this time -- that's fine (though I'd be curious if those that have used it in the past were using something like Capybara, which I find lessens the pain quite a bit).<br>



<br>However, I think it is important that we start to get our JavaScript under test, at least at the unit level. I suggest using <a href="https://github.com/jfirebaugh/konacha" target="_blank">Konacha</a>, a JS testing harness that I created and maintain. It's similar to Jasmine, though better integrated with the Rails asset pipeline and built using a newer, and better engineered, generation of JS testing libraries, <a href="http://visionmedia.github.com/mocha/" target="_blank">mocha</a> and <a href="http://chaijs.com/" target="_blank">chai</a>.
<div><br></div><div>Here's an example of what Konacha tests look like:</div><div><br></div><div><a href="https://github.com/jfirebaugh/openstreetmap-website/blob/28f40ba13bcb1c6fc4ae66cf6377def559ed73a2/test/javascripts/params_test.js" target="_blank">https://github.com/jfirebaugh/openstreetmap-website/blob/28f40ba13bcb1c6fc4ae66cf6377def559ed73a2/test/javascripts/params_test.js</a></div>


<div><br></div><div>Tests run in the browser -- while developing, re-running is as simple as refreshing the page. For CI, you can run them with Selenium or any other driver supported by Capybara. Check out the Konacha README for more details and let me know if you have any questions.</div>
<span class="HOEnZb"><font color="#888888">

<div><br></div><div>John</div>
</font></span><br>_______________________________________________<br>
rails-dev mailing list<br>
<a href="mailto:rails-dev@openstreetmap.org">rails-dev@openstreetmap.org</a><br>
<a href="http://lists.openstreetmap.org/listinfo/rails-dev" target="_blank">http://lists.openstreetmap.org/listinfo/rails-dev</a><br>
<br></blockquote></div><br></div>