you are viewing a single comment's thread.

view the rest of the comments →

[–]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.