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);
});
1
  • 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? Commented Sep 20, 2015 at 5:04

1 Answer 1

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?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.