...

View Full Version : testing .js files



EdR
02-02-2004, 06:26 PM
Hi all,

I'm new to the forum and relatively new to javascripting.

I'm wondering if there is a program out there that can test .js files. I'm interested in not having to test them manually by actually running them, but I'd be looking for a more automated way of doing it. I would be happy if all I had was some confirmation that they would load without error.

Anyone know of such a thing?

thanks in advance for your time and patience.
Ed

Philip M
02-02-2004, 06:53 PM
If a script has even one syntax error (such as for example a missing bracket) it will not run - as simple as that.

You need to test your scripts thoroughly for both run-time errors which throw when the script is run, and logic errors where syntax is correct but the outcome is not what was desired.

Testing is the msot important stage in the development of any program. You cannot skimp or short-circuit it.

EdR
02-02-2004, 07:06 PM
Hi, thanks for your reply.

Perhaps I did not make myself clear. I'm not looking to short circuit the testing process, but rather I'm looking to automate it.

If I have several hundred scripts to keep track of, it would be more efficient for me to be able to have a program checking it for me and reporting problems accordingly.

I guess I'm trying to find out if this is possible.

liorean
02-02-2004, 07:11 PM
Well, you can chech entirely destroyed scripts for syntax errors without finding any problems. However, most script errors depends on the document-script-browser interaction, and that is what you have to test - in all browsers you want it to run in.

EdR
02-02-2004, 07:19 PM
re:

"Well, you can chech entirely destroyed scripts for syntax errors"

How? Is there a program out there that does this?

I understand what you are saying regarding how the scripts interact with browsers, but I'm just trying to figure out what's going to work best for my situation.

thanks,
Ed

Tails
02-03-2004, 04:15 AM
There's no javascript validator. You'll have to carefully abide by the standards and test your scripts in various browsers until you are certain the bugs have all been worked out.

liorean
02-03-2004, 09:28 AM
jslint can help: <http://www.crockford.com/javascript/jslint.html>
After that, send it through mozilla with strict warnings enabled. See to that you don't cause ANY warnings. Then you send it through op7. And finally ie6w. Fix any bugs at current stage before moving on to the next one.

If it still doesn't work, insert alerts or prompts telling you the state of things before and after you change them. Alert types. Alert objects. Alert whether properties and methods exist or not.

Tails
02-03-2004, 06:34 PM
alerting the typeof() of a variable is also a useful debugger. And an alert('') can even be useful just to test if an if branching is going as planned.

I tried the jsint thing. It looks pretty useful. But I don't know how it's error reporting is. Example:

(3) : error at character 47: Bad HTML: :

Does that mean line 3, column 47? That's the doctype that's been w3c validated. :confused:

liorean
02-03-2004, 06:59 PM
Alerting typeof for objects, object members and variables was what I meant by "Alert types"...

I think jslint doesn't recognise DTDs. Try to enter only the JavaScript into it...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum