What should be tested in Javascript?
Posted
by
Nathan Hoad
on Programmers
See other posts from Programmers
or by Nathan Hoad
Published on 2011-11-15T09:11:22Z
Indexed on
2011/11/15
10:12 UTC
Read the original article
Hit count: 847
At work, we've just started on a heavily Javascript based application (actually using Coffeescript, but still), of which I've been implementing an automated test system using JsTestDriver and fabric.
We've never written something with this much Javascript, so up until now we've never done any Javascript testing. I'm unsure what exactly we should be testing in our unit tests. We've written JQuery plugins for various things, so it's quite obvious that they should be verified for correctness as much as possible with JsTestDriver, but everyone else in my team seems to think that we should be testing the page level Javascript as well.
I don't think we should be testing page level Javascript as unit tests, but instead using a system like Selenium to verify everything works as expected. My main reasoning for this is that at the moment, page level Javascript tests are guaranteed to fail through JsTestDriver, because they're trying to access elements on the DOM that can't possibly exist.
So, what should be unit tested in Javascript?
© Programmers or respective owner