While there’s certainly no shortage of testing frameworks for JavaScript, the vast majority of them require you to run your tests inside a web browser. If you’d rather test your JavaScript outside of a browser (and don’t want to use something heavy like RhinoUnit) Google’s newly released JS Test framework might be the ticket.
From the announcement:
Google JS Test is a JavaScript unit testing framework that runs on the V8 JavaScript Engine, the same open source project that is responsible for Google Chrome’s super-fast JS execution speed. Google JS Test is used internally by several Google projects, and we’re pleased to announce that it has been released as an open source project.
Keep in mind that since JS Test runs inside Google’s V8 your JavaScript won’t have access to the DOM. Google recommends you refactor your JavaScript to use as little DOM as possible then mock out the remaining DOM pieces using JS Test’s mocking facilities.