Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    EdR
    EdR is offline
    New to the CF scene
    Join Date
    Feb 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    testing .js files

    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

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,081
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    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.

  • #3
    EdR
    EdR is offline
    New to the CF scene
    Join Date
    Feb 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    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.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #5
    EdR
    EdR is offline
    New to the CF scene
    Join Date
    Feb 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #6
    Regular Coder
    Join Date
    Nov 2002
    Posts
    672
    Thanks
    1
    Thanked 1 Time in 1 Post
    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.

  • #7
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    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.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #8
    Regular Coder
    Join Date
    Nov 2002
    Posts
    672
    Thanks
    1
    Thanked 1 Time in 1 Post
    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.

  • #9
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    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...
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •