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

.labrc.js with --harmony options execute failed #668

Closed
TangMonk opened this issue Jan 15, 2017 · 6 comments
Closed

.labrc.js with --harmony options execute failed #668

TangMonk opened this issue Jan 15, 2017 · 6 comments
Assignees
Milestone

Comments

@TangMonk
Copy link
Contributor

@TangMonk TangMonk commented Jan 15, 2017

this following is config file:

module.exports = {
    coverage: true,
    threshold: 90,
};

when I run node --harmony ./node_modules/.bin/lab test/server/api/index.js

it will throw error:

SyntaxError: Unexpected token =>
    at Parser.instance.raise.instance.raiseRecoverable (/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/node_modules/.3.3.2@espree/espree.js:408:19)
    at Parser.instance.unexpected (/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/node_modules/.3.3.2@espree/espree.js:441:14)
    at Parser.pp.semicolon (/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/node_modules/.4.0.4@acorn/dist/acorn.js:593:59)
    at Parser.pp$1.parseVarStatement (/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/node_modules/.4.0.4@acorn/dist/acorn.js:963:8)
    at Parser.pp$1.parseTopLevel (/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/node_modules/.4.0.4@acorn/dist/acorn.js:658:23)
    at Object.parse (/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/node_modules/.3.3.2@espree/espree.js:735:21)
    at Object.internals.instrument (/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/node_modules/.11.2.2@lab/lib/coverage.js:238:25)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/node_modules/.11.2.2@lab/lib/coverage.js:31:55)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Function._load (/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/node_modules/.0.6.8@pmx/lib/transaction.js:62:21)
    at require (internal/module.js:20:19)
    at Object.exports.register (/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/server/api/index.js:5:122)
    at each (/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/node_modules/.16.1.0@hapi/lib/plugin.js:318:14)
    at iterate (/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/node_modules/.2.1.1@items/lib/index.js:36:13)
    at Object.exports.serial (/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/node_modules/.2.1.1@items/lib/index.js:39:9)
    at module.exports.internals.Server.internals.Plugin.register (/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/node_modules/.16.1.0@hapi/lib/plugin.js:321:11)
    at Items.serial (/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/node_modules/.4.1.0@glue/lib/index.js:119:24)
    at iterate (/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/node_modules/.2.1.1@items/lib/index.js:36:13)
    at done (/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/node_modules/.2.1.1@items/lib/index.js:28:25)
    at process.nextTick (/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/node_modules/.4.1.0@hoek/lib/index.js:854:22)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)
    at Module.runMain (module.js:607:11)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:535:3

But when I remove the options in .labrc.js, it works again

@geek

This comment has been minimized.

Copy link
Member

@geek geek commented Jan 15, 2017

What version of node are you trying this with? It looks like its having issues checking the code coverage, but you will have a syntax error like this if you are running on a version of node that doesn't recognize fat arrows.

@geek geek closed this Jan 15, 2017
@geek geek added non issue and removed non issue labels Jan 15, 2017
@geek geek reopened this Jan 15, 2017
@geek geek self-assigned this Jan 15, 2017
@TangMonk

This comment has been minimized.

Copy link
Contributor Author

@TangMonk TangMonk commented Jan 16, 2017

@geek i am using Node 7.4.0

test code is below:

index.js:

const Code = require('code');   // assertion library
const Lab = require('lab');
const lab = exports.lab = Lab.script();

lab.test('returns true when 1 + 1 equals 2', async () => {
    Code.expect(1 + 1).to.equal(2);
});

.labrc.js:

module.exports = {
    coverage: true,
    threshold: 90,
};

when execute:

➜  lab_test node --harmony ./node_modules/.bin/lab index.js
/Users/tangmonk/Downloads/lab_test/node_modules/espree/espree.js:412
        throw err;
        ^

SyntaxError: Unexpected token =>
    at Parser.instance.raise.instance.raiseRecoverable (/Users/tangmonk/Downloads/lab_test/node_modules/espree/espree.js:408:19)
@Marsup

This comment has been minimized.

Copy link
Member

@Marsup Marsup commented Jan 16, 2017

I would bet lab doesn't know how to deal with async from a coverage point of view, you're using experimental features, expect some breakage.

@TangMonk

This comment has been minimized.

Copy link
Contributor Author

@TangMonk TangMonk commented Jan 16, 2017

@Marsup it seems lab using espree as a javascript parser, it do not support async/await now, or espree is not newest

@TangMonk

This comment has been minimized.

Copy link
Contributor Author

@TangMonk TangMonk commented Jan 16, 2017

I found where the problem is:

this line ecmaVersion: 6 in:
https://github.com/hapijs/lab/blob/master/lib/coverage.js#L242

I change it to latest 8, it works

so, can i open a pull request for this?

@geek

This comment has been minimized.

Copy link
Member

@geek geek commented Jan 17, 2017

Fixed by #670

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.