1

I am using Intern.js to do functional testing and ran into the error in the title. I have no clue how to load json files through FS or through require. I tried everything on Google.

Here's the code in question.

var fs = require('intern/dojo/node!fs')

fs.readFile('./test.json', function (err, data) {
    if (err) throw err; // we'll not consider error handling for now
    var obj = JSON.parse(data);
});
Bran
  • 617
  • 8
  • 21
  • It's unclear how much context you're leaving out of that code. Are you wrapping that in an AMD define, as shown in [the examples](http://theintern.github.io/intern/#testing-commonjs-code)? – Ken Franqueiro Sep 20 '15 at 05:04

1 Answers1

0

I ended up doing it this way to make it work:

define([
    'intern!object',
    'intern/chai!assert',
    'intern/dojo/node!fs'
],
function(registerSuite, assert, fs) {
    ...
});

Idea from here: How do I load the node.js http module from within an intern.js test?

Community
  • 1
  • 1
Bran
  • 617
  • 8
  • 21