Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES6 String Templates Throw Errors #1548

Closed
Tivoli opened this issue Feb 12, 2015 · 14 comments
Closed

ES6 String Templates Throw Errors #1548

Tivoli opened this issue Feb 12, 2015 · 14 comments
Labels
status: waiting for author waiting on response from OP - more information needed

Comments

@Tivoli
Copy link

Tivoli commented Feb 12, 2015

String templates even when the --harmony flag is set for mocha throws a token ILLEGAL error;

Simple before to replicate.

before(function() {
  let a = 1;
  console.log(`${a}`);
});
  console.log(`${a}`);
              ^
SyntaxError: Unexpected token ILLEGAL
    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 <redacted>/node_modules/mocha/lib/mocha.js:185:27
    at Array.forEach (native)
    at Mocha.loadFiles (/Users/Tivs/Documents/github/nurfed/curio-node/node_modules/mocha/lib/mocha.js:182:14)
    at Mocha.run (<redacted>/node_modules/mocha/lib/mocha.js:394:31)
    at Object.<anonymous> (<redacted>/node_modules/mocha/bin/_mocha:394:16)
    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:124:16)
    at node.js:842:3
@dasilvacontin dasilvacontin added status: waiting for author waiting on response from OP - more information needed Unconfirmed labels Feb 12, 2015
@boneskull
Copy link
Contributor

@dasilvacontin What feedback do we need?

@boneskull
Copy link
Contributor

Actually I know what we need.

@Tivoli Need to know exactly how you are executing Mocha, if you have a mocha.opts, etc.

@Tivoli
Copy link
Author

Tivoli commented Feb 12, 2015

I do not have have a mocha.opts file, I'm executing it from the following Makefile.

default: test
NODE_ENV = test
REPORTER = dot
CFLAGS = -c -g -D $(NODE_ENV)

# Find all test files
SPECS = $(shell find ./test/specs -type f -name "*.js")
ACCEPTANCE = $(shell find ./test/acceptance -type f -name "*.js")

test:
    @NODE_ENV=$(NODE_ENV) ./node_modules/.bin/mocha \
        --harmony \
        --reporter $(REPORTER) \
        --require co-mocha \
        --timeout 10s \
        --bail \
        test/spec_helper.js \
        $(SPECS) \
        $(ACCEPTANCE)

.PHONY: test

I removed the co-mocha require with the same result.

@domenic
Copy link
Contributor

domenic commented Feb 14, 2015

This is probably because the version of node you are using does not support template strings (even with --harmony). io.js is the only release that supports template strings right now.

@Tivoli
Copy link
Author

Tivoli commented Feb 15, 2015

@domenic I am using io.js, my app runs fine and is using template strings. The node executable is also symlinked to io.js.

@domenic
Copy link
Contributor

domenic commented Feb 15, 2015

Ah OK hmm nevermind then I am totally wrong! I still have a hard time understanding what could cause this in that case but who knows.

@boneskull
Copy link
Contributor

@domenic Ahh, this gives me something to go on.

@Tivoli Please try running iojs --harmony /path/to/_mocha <args>

@Tivoli
Copy link
Author

Tivoli commented Feb 15, 2015

@boneskull That works.

@dasilvacontin
Copy link
Contributor

#!/usr/bin/env node at mocha bin (?)

@boneskull
Copy link
Contributor

@dasilvacontin What are you asking?

@boneskull
Copy link
Contributor

@Tivoli So iojs is not symlinked to node on your system? I don't think we can support that setup--at least not yet.

@Tivoli
Copy link
Author

Tivoli commented Feb 15, 2015

@boneskull It is symlinked. node --harmony /path/to/_mocha <args> works fine as well.

@boneskull
Copy link
Contributor

@Tivoli If you clone master (then npm install && npm link I suppose), executing mocha like normal should work correctly. At least it has in my limited testing against iojs.

@aMarCruz
Copy link

aMarCruz commented Jun 5, 2015

On Windows, change this line:

@NODE_ENV=$(NODE_ENV) ./node_modules/.bin/mocha \

to

@NODE_ENV=$(NODE_ENV) ./node_modules/mocha/bin/mocha \

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for author waiting on response from OP - more information needed
Projects
None yet
Development

No branches or pull requests

5 participants