I am working on a test suite and I came across this dilemma:
Importing ES6 js from a file with require or with import?
I am currently using mocha and chai for testing, with babel already configured.
Now I came up with a solution but I believe it is not "good practice", in fact after some trial and mainly one error stating that TypeError: Object #<Object> has no method 'getUsers'
I found that if I:
export default Utils;
where Utils is an object, and inside my (ES5) test suite I
var util = require('./../src/utils/Utils');
it triggers the mentioned error. Same if I try the ES6 version:
import Utils, * as util from './../src/utils/Utils';
While if I
import Utils from './../src/utils/Utils';
var util = Utils;
it works, can someone explain me why is that?
I probably need to specify that util get used by calling one of the functions defined inside the Util object exported, like: util.functionName();