jasmine-node icon indicating copy to clipboard operation
jasmine-node copied to clipboard

Run jasmine node with --harmony flag for ES6 generator support

Open nguyenxuantuong opened this issue 11 years ago • 15 comments

I am currently trying to use jasmine-node to run nodejs 0.11.x code with generator support. Unfortunately, I can't just simply run jasmine-node --color --autotest --harmony server/tests/GeneratorSpec.js I was able to run manually using: node --harmony /lib/jasmine-node/cli.js --color server/tests/GeneratorSpec.js but when adding --autotest, it just throw the error: Unexpected token *] How i can run jasmine with hamony flag. Thanks!

nguyenxuantuong avatar Jul 26 '14 16:07 nguyenxuantuong

In case if anyone has had the same problem, i was able to resolve it by by modifying the file 'autotest.js' of jasmine-node. Adding the --harmony flag so that child process will run node with harmony flag. baseArgv.splice(1, 0, '--harmony');

nguyenxuantuong avatar Jul 27 '14 05:07 nguyenxuantuong

+1

xpepermint avatar Aug 16 '14 22:08 xpepermint

+1

petehunt avatar Aug 23 '14 03:08 petehunt

+1

ghost avatar Nov 11 '14 21:11 ghost

+1

rockdragon avatar Nov 17 '14 12:11 rockdragon

+1

mwilc0x avatar Mar 15 '15 00:03 mwilc0x

+1

aliengoo avatar Mar 28 '15 10:03 aliengoo

+1

falsandtru avatar May 21 '15 17:05 falsandtru

Where does the line baseArgv.splice(1, 0, '--harmony'); get added in autotest.js?

datatypevoid avatar Aug 01 '15 00:08 datatypevoid

+1

khanghoang avatar Aug 02 '15 12:08 khanghoang

+1

Posia avatar Dec 02 '15 15:12 Posia

+1

goto100 avatar Jun 20 '16 08:06 goto100

+1

xfg avatar Nov 26 '16 20:11 xfg

+1

iEchoic avatar Dec 31 '16 22:12 iEchoic

Since people are still +1-ing this...

First, ES6 generators are definitely working out of the box as of the node 7.3.0. A workaround for those features which are not available*, such as harmony_async_await is as follows.

Begin by locating the jasmine command with where jasmine or which jasmine

For windows, grab the following lines "%~dp0\node.exe" "%~dp0\node_modules\jasmine\bin\jasmine.js" %* node "%~dp0\node_modules\jasmine\bin\jasmine.js" %*

and make them look like: "%~dp0\node.exe" --harmony_async_await "%~dp0\node_modules\jasmine\bin\jasmine.js" %* node --harmony_async_await "%~dp0\node_modules\jasmine\bin\jasmine.js" %*

Linux instructions should be rather similar. Actually i think Linux people can simply alias node out into node with the flags. http://www.linfo.org/alias.html

*I'm not sure what the autotest.js the OP was talking about

blackening avatar Dec 31 '16 23:12 blackening