Google releases JS Test

Posted by Peter J. Jones on

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.

About the Author

Peter J. Jones has been a professional software engineer for over 20 years and is deeply passionate about helping programmers improve the skills of their craft. He is the author of Effective Ruby: 48 Specific Ways to Write Better Ruby. Peter can be reached through our contact page or his twitter account.