Access Native Node.js Modules within Intern
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!
![From Webcam to Animated GIF: the Secret Behind chat.meatspac.es!]()
My team mate Edna Piranha is not only an awesome hacker; she's also a fantastic philosopher! Communication and online interactions is a subject that has kept her mind busy for a long time, and it has also resulted in a bunch of interesting experimental projects...
![CSS Gradients]()
With CSS border-radius, I showed you how CSS can bridge the gap between design and development by adding rounded corners to elements. CSS gradients are another step in that direction. Now that CSS gradients are supported in Internet Explorer 8+, Firefox, Safari, and Chrome...
![Generate Dojo GFX Drawings from SVG Files]()
One of the most awesome parts of the Dojo / Dijit / DojoX family is the amazing GFX library. GFX lives within the dojox.gfx namespace and provides the foundation of Dojo's charting, drawing, and sketch libraries. GFX allows you to create vector graphics (SVG, VML...
![Facebook-Style Modal Box Using MooTools]()
In my oh-so-humble opinion, Facebook's Modal box is the best modal box around. It's lightweight, subtle, and very stylish. I've taken Facebook's imagery and CSS and combined it with MooTools' awesome functionality to duplicate the effect.
The Imagery
Facebook uses a funky sprite for their modal...
Seems like it’d be a lot easier to use the default require/exports/module style, so that your test module feels a lot more like Node. The above code could be written like so:
Still unfortunate that you have to go through
intern/dojo/node
but it works.It’s also in line with the conventions as prescribed in the Intern user guide at https://theintern.github.io/intern/#testing-commonjs-code