As Node.js continues to gain adoption, there is an increasing need for tools to help test the applications built on it. When cloud hosting provider Rackspace started to use Node.js and ran up against the testing requirement, they wrote their own testing tool for Node.js applications called Whiskey.
Whiskey is an open source test automation stack that Rackspace is using within its own infrastructure. Although Rackspace officially announced the Whiskey project only this week, the company has been using it internally for nearly two years. Since its inception, the project has also been open source.
"We put the project on GitHub, but we didn't have a polished Read Me and things like that," said Tomaz Muraus, software developer at Rackspace. "We figured that now was about the right time to announce it. We've added features over time and at this point it's one of the best test frameworks for Node.js."
Alex Polvi, director of product for Rackspace, explained that Rackspace bet on Node.js early, when Node.js was still a really young product with few available tools. That's why they decided to write their own test framework. Rackspace needed to ensure that their test stack had proper code coverage and orchestration capabilities.
"When we designed Whisky, we designed it with scalability in mind," said Muraus.
Currently, Whiskey will run in a single process but Muraus explained that the platform has a master process that spawns child processes and communicates with them over TCP. The plan is to enable a Whiskey Node.js test to run across multiple servers.
Pre-production Code Testing for Node.js Apps
Rackspace runs Whisky in its development environment prior to releasing code into the live production environment.
"We develop most of our new cloud-monitoring technology on Node.js," said Polvi. "So we're using Node to build another product."
"The path to becoming production code involves Whiskey running on it," Polvi said. "After the developer commits, Whiskey runs and if we so choose, we then press a button that deploys that code into production."
As part of the pre-production code testing, Whiskey provides multiple reporting tools to help developers identify any potential issues with their Node.js code. Muraus explained that there is a simple text-based report that is an output of the Whiskey console. There is also an HTML report that generates a page that shows the test report and code coverage results.
"There is also a JSON output that we use to publish the results to a separate server," Muraus said.
The JSON results can be used to track timing, for example, so test results can be monitored over time. Muraus added that the Whiskey system is also linked with Git for version control.
"So we can basically map every commit to how long it took," Muraus said. "So then we know if we added something that introduces a regression."
"For example, you define a variable but you forget the var keyword, which basically says that the variable is local scope," Muraus explained. "If you do that, it could corrupt or change the state."
To help solve that issue, Whiskey has functionality that reports on all the variables, which helps to identify some developer errors.
Rackspace announced the release of Whiskey to the open source community on March 14, 2012. The test framework is available on the Whiskey GitHub page.