2

I'm new to nodejs, and am not sure how I can enable harmony features in nodeunit?

I know I can enable them in node by using the --harmony flag, but nodeunit does not have this flag. I'm looking specifically to make let work.

simonzack
  • 19,729
  • 13
  • 73
  • 118

3 Answers3

2

This might not work for all cases, but we can add the --harmony flag in the nodeunit startup script:

batch:

@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe" --harmony "%~dp0\..\nodeunit\bin\nodeunit" %*
) ELSE (
  node --harmony "%~dp0\..\nodeunit\bin\nodeunit" %*
)

sh:

#!/bin/sh
basedir=`dirname "$0"`

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
  "$basedir/node" --harmony "$basedir/../nodeunit/bin/nodeunit" "$@"
  ret=$?
else 
  node --harmony "$basedir/../nodeunit/bin/nodeunit" "$@"
  ret=$?
fi
exit $ret
simonzack
  • 19,729
  • 13
  • 73
  • 118
1

On Linux, if you have nodeunit installed globally (npm install -g nodeunit), this works just fine:

node --harmony `which nodeunit` /path/to/tests
Andrey Agibalov
  • 7,624
  • 8
  • 66
  • 111
0

On a Mac with the default install locations, a quick one liner:

node --harmony /usr/local/bin/nodeunit /path/to/your/testFile.js 
Jeff Jolma
  • 46
  • 2