Automatically testing a website for JavaScript errors in IE7?
This week I decided to add a new element to the javascript array by copying a similar line from the previous line; unfortunately I forgot to remove the comma, so the end result was something like var a = [1, 2, 3,]
.
The code aired late Friday afternoon before everyone left for the weekend, and it completely broke everything in Internet Explorer 7 (and as I assume below) since it's such a great browser. Since there was no one to read the emails (weekends) this went on for quite a while and I really don't want something like this to be repeated (especially in my code).
This isn't the first of IE7's strange problems; I was wondering if there is a way to automatically check for key pages looking for javascript or css errors, or really whatever IE8 will output to its new console in development tools.
If it doesn't, what do you usually do? Do you check the site after every change with all supported browsers? (Something I will do from now on, at least for IE, if there is no way to run automated tests)
a source to share
Found a solution; we use a YUI compressor to compress our javascript files, but google closure has a lot of error detection capabilities along with a better compression ratio:
There is no compiled code because there are errors.
Number of errors: 1 JSC_TRAILING_COMMA: analysis error.
Internet Explorer has a non-standard interpretation of trailing commas. Arrays will have the wrong length and objects won't be parsed at all. on line 1 character 18
a source to share
What I suggested on one project at a company where I work part time was automated testing using Selenium RC. It is open source, can run various browsers, can be integrated into xUnit testing tools, and provides the Selenium IDE, a simple tool for writing tests. Check it out: http://seleniumhq.org/
a source to share