1

Is it possible to check the validity of your JavaScript code, even modern techniques and JavaScript calls with some form of validity checker? I have seen some that check JavaScript but about with the combination of your HTML document, possibly with CSS, possibly 'src' include path, etc?

And what are the normal approaches for this type of testing?

3
  • Are you trying to validate links/syntax errors/etc, or make sure your ajax code (or other such client-side functionality) works correctly? Commented Mar 27, 2011 at 5:32
  • Not functionality but just that everything compiles and I guess in some cases try to avoid null references to parts of the DOM that don't exist. Commented Mar 27, 2011 at 5:36
  • Usually people run validity checkers over their code. They tend to write unit tests to assert functionality, not syntax/dead links. Not sure which validity checkers are best for combined scenarios like this, though. I believe it is good style to split up your documents, so you have your js/css/html content in separate files. Commented Mar 27, 2011 at 5:58

2 Answers 2

2

JS Unit - https://github.com/pivotal/jsunit : Simple JavaScript unit test framework. Use it to check your code.

Selenium - http://seleniumhq.org/ : Use it to test your sites interface.

Use http://browsershots.org/ (free) to test the look of your site in different rendering engines.

If you maintain some semblance of testing there should be no need to make sure your code "validates", as perfectly valid code carries no guarantee of doing what you want it to.

Sign up to request clarification or add additional context in comments.

2 Comments

And if it does what you want it to, it implicitly should pass a validator.
If he is using some form of source control, I see no harm (and some good) in using validators before check-in. It would catch typos or stupid mistakes before having to loop through test, which might be a separate team, and might lag behind development. If he does this, though, I'd recommend it be done automatically via scripts, rather than doing it manually each time.
0

If you're doing interface testing it's best to go with a framework like Selenium : http://seleniumhq.org/

You can create test suites and run them automatically when you do changes to your front end to make sure everything is still working as you expect.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.