I'm getting the error Attempt to require unloaded module xxxxxx
with the following intern.js test (myfile.js below does a require('xxxxxx')
) for testing NodeJS.
define(function(require) {
var bdd = require('intern!bdd');
var myfile = require('../myfile.js');
bdd.describe('the thing being tested', function() {
bdd.it('do the test', function() {
...
The directory structure is
intern.js
myfile.js
test
|-- test.js
How do I properly require a file? There's no examples on how to do it with the BDD test interface. There are examples of doing it with the other style like in How do I load the node.js http module from within an intern.js test? but that doesn't use BDD.
Does it have anything to do with properties I need to set in intern.js file?
require
works the same with any of the Intern interfaces. The tricky part is that the AMD require (which you're using in the code above) is not the same as Node's require (which is what you need to use to load Node modules).If
myfiles.js
is a node module, you'll need to use Dojo'snode
plugin to load it, like: