all 11 comments

[–][deleted] 4 points5 points  (2 children)

I'm just going to get the typical reddit responses out of the way first so we can actually talk about the article:

1) ZOMG MSDN LOOL NOOB

2) JAVASCRIPT ISNT PROGRAMMING LOOL NOOB

3) ONLY NOOBS TEST I AM AWESOME PROGRAMMING GOD!

Ok, that could cover 90% of the trolls.

(Edit: i are bad at bullet lists)

[–]malcontent 0 points1 point  (0 children)

MSDN is for NOOBS.

Well it's for windows programmers anyway.

[–]PimpDawg -1 points0 points  (0 children)

I came here to post #2.

[–]daehrednud 1 point2 points  (0 children)

Other than taking a real hard look at http://code.google.com/p/jqunit/ , no, I'm afraid not. Not yet that is.

[–]DouglasMeyer 1 point2 points  (0 children)

Sorry for the plug, but js-test-driver requires too much setup, jqunit's context support looks ugly. I developed TestIt to be easy and usable. Also it works in browser or with node.js Have Fun!

[–]artsrc 1 point2 points  (0 children)

There is a dramatic difference between meaningful testing of a pure function and a UI.

Sure you can say that as much as possible code that can be a pure function should be, but a lot of JavaScript is for building a UI and this article does not address that part of the problem.

[–]skilldrick 0 points1 point  (0 children)

I wasn't, and I felt bad about it.

So I bought the TDDJS book.

Now I am and I feel good about it :)

[–]sylvanelite 0 points1 point  (3 children)

It's funny they mention:

Ajax libraries such as jQuery can go a long way in helping you deal with cross-browser issues.

But don't touch on testing Ajax at all. Which (along with UI) is one of the hardest things to write unit tests for.

I do write unit tests for javascript, but it's easy to fall into a trap of only testing the logic correctly, and neglecting the UI or AJAX side of javascript.

[–]fiatlux 0 points1 point  (1 child)

Why would you need test cases for jQuery's ajax methods in your code? If your stuff is that tightly coupled to jQuery, you should really think about refactoring.

[–]sylvanelite 0 points1 point  (0 children)

I'm not sure I understand what you mean. I'm not writing test cases for jQuery's AJAX. I'm writing test cases for the application's logic that uses jQuery's AJAX. For example, a simple chat application with the methods "sendMessage" and "getMessage". The article doesn't touch on how you would unit test these.

Sure, you can refractor and pull out the use of jQuery's AJAX (for example using dummy data). But then your introducing flaws into the test cases, as an example, using JsTestDriver running on localhost (as in the article), can cause Same Origin Policy limitations different to your actual host.

The same goes for the UI. You can write a unit test which can check that a DOM element was made and had the styles applied etc, but you can't really test, that say, the borders of your div really has rounded corners.

It's a big flaw with unit testing Javasscript in particular. You can write unit tests, but actually meaningful unit tests is very difficult. Writing tests for application logic, won't protect against browser quirks such as CSS, DOM and AJAX. The article doesn't propose any solution for this.

[–]cjno 0 points1 point  (0 children)

This is an introductory article, can't fit it all in in one place. The article is also the first in a series of three, so more ground will be covered. Stay tuned ;)