eventuate-clients / eventuate-client-nodejs

Other
4 stars 3 forks source link

Cannot npm test: SyntaxError: Use of const in strict mode. #37

Open cer opened 7 years ago

cer commented 7 years ago
Chriss-MacBook-Pro-2:eventuate-nodejs-client cer$ npm test

> @eventuateinc/eventuate-nodejs-client@1.0.12 test /Users/cer/src/eventuate/eventuate-nodejs-client
> mocha --reporter spec --ui bdd test/*-spec.js

/Users/cer/src/eventuate/eventuate-nodejs-client/test/AckOrderTracker-spec.js:3
const AckOrderTracker =require('../dist/modules/stomp/AckOrderTracker');
^^^^^
SyntaxError: Use of const in strict mode.
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at /Users/cer/src/eventuate/eventuate-nodejs-client/node_modules/mocha/lib/mocha.js:216:27
    at Array.forEach (native)
    at Mocha.loadFiles (/Users/cer/src/eventuate/eventuate-nodejs-client/node_modules/mocha/lib/mocha.js:213:14)
    at Mocha.run (/Users/cer/src/eventuate/eventuate-nodejs-client/node_modules/mocha/lib/mocha.js:453:10)
    at Object.<anonymous> (/Users/cer/src/eventuate/eventuate-nodejs-client/node_modules/mocha/bin/_mocha:393:18)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3
npm ERR! Test failed.  See above for more details.
Chriss-MacBook-Pro-2:eventuate-nodejs-client cer$ ls -lt dist/
cer commented 7 years ago

I read this blog: http://jamesknelson.com/testing-in-es6-with-mocha-and-babel-6/

Made this change:

$ git diff
diff --git a/package.json b/package.json
index 321110e..e684f05 100644
--- a/package.json
+++ b/package.json
@@ -20,6 +20,7 @@
   },
   "devDependencies": {
     "babel-cli": "^6.9.0",
+    "babel-core": "^6.21.0",
     "babel-plugin-add-module-exports": "^0.1.4",
     "babel-preset-es2015": "^6.3.13",
     "babel-preset-stage-0": "^6.3.13",

And ran it with this command:

mocha --compilers js:babel-core/register --reporter spec --ui bdd test/*-spec.js