Closed rburgst closed 8 years ago
If you run mocha from the command line does it work?
Unexpected reserved word points at using es6 features that aren't available in the atom context without a transpiler in play. You can use the require
parameter in mocha.opts to include babel or traceur.
Yes, from the command line it works fine. You can reproduce this problem by running atom in the "todomvc" example dir from redux: https://github.com/rackt/redux/tree/master/examples/todomvc
Ah, it works using npm test
I imagine?
That npm test command does a few things including passing the compiler and require parameters.
This extension requires parameters passed through mocha.opts .... if these same parameters were present i imagine it would work.
With straight mocha
I'm not sure if it will work.... although this likely depends what they are doing and whether these symbols are available in the installed node runtime (off hand I'm not sure if atom has updated their runtime to >= 4... even then, moot point if they use import
over require)
I'm just responding via phone at the airport.... will look into this more in depth when I reach my destination.
Ah yes, here's the full stack running just mocha -- they do indeed use import so it totally dies in the absence of the babel.
C:\code\redux\examples\todomvc>node_modules\.bin\mocha.cmd
C:\code\redux\examples\todomvc\test\setup.js:1
(function (exports, require, module, __filename, __dirname) { import { jsdom } from 'jsdom'
^^^^^^
SyntaxError: Unexpected token import
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at C:\code\redux\examples\todomvc\node_modules\mocha\lib\mocha.js:216:27
at Array.forEach (native)
at Mocha.loadFiles (C:\code\redux\examples\todomvc\node_modules\mocha\lib\mocha.js:213:14)
at Mocha.run (C:\code\redux\examples\todomvc\node_modules\mocha\lib\mocha.js:453:10)
at Object.<anonymous> (C:\code\redux\examples\todomvc\node_modules\mocha\bin\_mocha:393:18)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:430:10)
at startup (node.js:141:18)
at node.js:980:3
C:\code\redux\examples\todomvc>node --version
v5.3.0
One thing though, the npm test command also sets up NODE_ENV to be testing which cannot be done in mocha.opts (see https://github.com/mochajs/mocha/issues/185)
There's not much the extension can do here aside from executing what is in the npm test command. For what it's worth, the way in which the todomvs sets the environment variable is not done in a platform indepdendent way - even if I passed whatrever it was to the shell module it would have failed on my system.
Most of the options here around fixing the unexpected token can be fixed by passing the compile and require parameters via mocha.opts.... and there's not much the plugin can do around their reliance on NODE_ENV being testing.
just try and run tests in a mocha project.
Atom Version: 1.3.1 System: Mac OS X 10.11.2 Thrown From: mocha-runner package, v1.1.8
Stack Trace
Uncaught Error: Unexpected reserved word
Commands
Config
Installed Packages