Skip to content Skip to sidebar Skip to footer

How Do I Load The Node.js Http Module From Within An Intern.js Test?

I am attempting to use the Intern test framework to automate testing of a simple REST API implemented with node.js and StrongLoop. StrongLoop provides an explorer web page that I

Solution 1:

Intern runs its tests in an AMD environment, so require is the AMD loader's require, not Node's, hence your error.

To load Node modules, use the intern/dojo/node! AMD plugin and include them in your module's dependencies, e.g.:

define([
    ...,
    'intern/dojo/node!http'
], function (..., http) {
    // Now http contains the exports of Node's http module
});

This is documented in Intern's User Guide under Testing CommonJS Modules.

Post a Comment for "How Do I Load The Node.js Http Module From Within An Intern.js Test?"