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!
![CSS 3D Folding Animation]()
Google Plus provides loads of inspiration for front-end developers, especially when it comes to the CSS and JavaScript wonders they create. Last year I duplicated their incredible PhotoStack effect with both MooTools and pure CSS; this time I'm going to duplicate...
![Conquering Impostor Syndrome]()
Two years ago I documented my struggles with Imposter Syndrome and the response was immense. I received messages of support and commiseration from new web developers, veteran engineers, and even persons of all experience levels in other professions. I've even caught myself reading the post...
![Dynamically Create Charts Using MooTools MilkChart and Google Analytics]()
The prospect of creating graphics charts with JavaScript is exciting. It's also the perfect use of JavaScript -- creating non-essential features with unobtrusive scripting. I've created a mix of PHP (the Analytics class), HTML, and MooTools JavaScript that will connect to Google Analytics...
![Detect DOM Node Insertions with JavaScript and CSS Animations]()
I work with an awesome cast of developers at Mozilla, and one of them in Daniel Buchner. Daniel's shared with me an awesome strategy for detecting when nodes have been injected into a parent node without using the deprecated DOM Events API.
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