As per the title, I'm trying to test some AMD modules written in ES6 JS, running from nodejs.
I tried first with Intern: even after enabling --harmony
in nodejs, I ended up facing Intern's dependency chain, where I was not able to enable Harmony in e.g. Istanbul, esprima and others (I opened an issue for that).
I then moved onto mocha, and here I'm stuck ... strangely. I enabled Harmony both for nodejs and mocha itself, here's the package.json
test script:
"test": "node --harmony node_modules\\mocha\\bin\\mocha tests --harmony --recursive"
that I run from command prompt as npm test my_test_folder
. Still, some ES6 constructs (like const
) pass ok, but then it chokes on destructuring assignment. Here are the first output lines:
const { log, dir } = require('../consoleLogger.js');
^
SyntaxError: Unexpected token {
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
[...continues...]
I've also checked this SO thread and heard about transpilers, but I don't really know if they could work and I'm now trying to make transpilers work in this case.
Any idea on how to solve this, without resorting to change all ES6 bits spread in code? TA.