Andreas Bonini
Andreas Bonini

Reputation: 44742

Automated testing of a website for IE7 javascript errors?

This week I decided to add a new element to a javascript array by copying a similar one from a previous line; unfortunately I forgot to remove the comma so the end result was something like var a = [1, 2, 3,].

The code went live late Friday afternoon just before everyone left for the week-end, and it completely broke everything in Internet Explorer 7 (and lower I assume) since it's such a great browser. Since there was no one to read emails (week-end) it went unnoticed for quite a while, and I really don't want something like this to happen again (especially in my code)..

This is not the first of weird IE7 problems; I was wondering if there was a way to automatically test key pages looking for javascript or css errors, or really anything that IE8 would output in its new console in development tools.

If there isn't, what do you usually do? You test the website after every change with all the browsers you support? (Something I'll do from now, at least for IE, if there is no way to run automated tests)

Upvotes: 2

Views: 965

Answers (2)

Andreas Bonini
Andreas Bonini

Reputation: 44742

Found a solution; we use the YUI compressor to compress our javascript files but google closure has a lot of error detection capabilities along with a better compression rate:

No compiled code because there were errors.

Number of errors: 1 JSC_TRAILING_COMMA: Parse error.
Internet Explorer has a non-standard interpretation of trailing commas. Arrays will have the wrong length and objects will not parse at all. at line 1 character 18

Upvotes: 2

Gabriel Ščerbák
Gabriel Ščerbák

Reputation: 18560

What I proposed in one project at company where I am working part time, was automated testing using Selenium RC. It is open source, can run different browsers, can be integrated into xUnit testing tools and provides Selenium IDE, easy tool for recording tests. Check it out: http://seleniumhq.org/

Upvotes: 2

Related Questions