Since it doesn't need a browser, tests can be carried out very fast

Sep 30, 2011 14:43 GMT  ·  By
Google is open sourcing its internal Google JS Test, JavaScript unit testing framework
   Google is open sourcing its internal Google JS Test, JavaScript unit testing framework

The web is more dependent on JavaScript than ever. And the coding language is spreading more and more beyond the web. There are some that are calling for an alternative, but JavaScript is not going anywhere any time soon.

But as more complex projects rely on JavaScript, there is a need for better testing and debugging tool. Google is now open sourcing something from the first category, Google JS Test, a unit testing framework that doesn't require a browser to run.

It relies on Google's V8 JavaScript engine, the same one used by Chrome and Chromium, to run JavaScript code.

"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," Aaron Jacobs, a Google engineer, explained.

"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," he said.

Since it's bundled around V8, there's no need for a browser. This means that a test can start in seconds with minimum impact on the computer's resources.

This also grants more flexibility in setting up and running the tests. That said, the test can be run inside a browser as well, if there's a need for it.

If you've used Google Test for C++, the style and semantics should feel familiar. There are several other touting points.

"A built-in mocking framework that requires minimal boilerplate code (e.g. no $tearDown or $verifyAll calls), with style and semantics based on the Google C++ Mocking Framework," Jacobs explained.

"A system of matchers allowing for expressive tests and easy to read failure output, with many built-in matchers and the ability for the user to add their own," he added.

Google JS Test is available under an Apache License 2.0, so people are going to be able to do pretty much what they want with the framework. You can grab the code here.