Intern is an awesome unit and functional test suite from SitePen.  I’ve been using this utility extensively over the past year, writing tests to make sure MDN’s front-end is in good shape after code merges and pushes.

Sometimes when writing tests I’ll want to make use of a node module to accomplish a test task, like making an HTTP request or getting environment information.  It isn’t as easy as making the same dependency path you would if you were writing a node module — you’re using the Dojo loader so you’ll need to require those modules a bit differently:

define([
	'intern/dojo/node!http',
	'intern/dojo/node!process'
], function(http, process) { 

	// http and process now available from the Node.js environment

});

The dojo/node Dojo module gives your Intern test suite the ability to access native Node.js modules!

Source: David Walsh

Leave a Reply