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

Unexpected token ... with nyc 12.0.2, jasmine, and babel-plugin-istanbul #865

Closed
zvchei opened this issue Jun 13, 2018 · 3 comments
Closed

Comments

@zvchei
Copy link

zvchei commented Jun 13, 2018

Expected Behavior

Tests are executed and coverage is reported.

Observed Behavior

An exception is thrown:

home/cabox/workspace/nyc-test/node_modules/nyc/node_modules/@babel/types/lib/builders/generated/index.js:228
function ArrayExpression(...args) {
                         ^^^

SyntaxError: Unexpected token ...
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/cabox/workspace/nyc-test/node_modules/nyc/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js:8:18)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)

Bonus Points! Code (or Repository) that Reproduces Issue

I have a simple source file and a unit test, both written in ES6.

src:
  test.js

test:
  test.spec.js

Also, in package.json:

"devDependencies": {
    "babel-core": "^6.26.3",
    "babel-plugin-istanbul": "^4.1.6",
    "babel-preset-env": "^1.7.0",
    "jasmine": "^3.1.0",
    "nyc": "^12.0.2"
}

.babelrc:

{
  "presets": ["env"],
  "env": {
    "test": {
      "plugins": [
        "istanbul"
      ]
    }
  }
}

.nycrc (or in package.json):

{
    "require": [
        "babel-core/register"
    ],
    "sourceMap": false,
    "instrument": false,
    "cache": false
}

Executing the following line throws the exception:
NODE_ENV=test ./node_modules/.bin/nyc ./node_modules/.bin/jasmine test/test.spec.js

If I delete the .nycrc config and specify babel-reqiester in the command line the unit tests are executed and the coverage is shown correctly, however there are errors/warnings in the console.

> NODE_ENV=test ./node_modules/.bin/nyc --require babel-core/register ./node_modules/.bin/jasmine test/test.spec.js

Transformation error for /home/cabox/workspace/nyc-test/src/test.js ; return original code
Unexpected token ...

The issue affects 12.0.0+. The older versions (like 11.9.0) work well.

Forensic Information

Operating System: Ubuntu 14.04 LTS
Environment Information:

node --version
v4.4.0

npm --version
3.8.1
@coreyfarrell
Copy link
Member

nyc 12.0.0 updated from babel 6 to babel 7, this drops support for node 4.x, node 6 is required for nyc 12 and up. Note babel-plugin-istanbul 4.1.6 still uses babel 6 but my intent is for 5.0.0 to use babel 7 as well.

See 19b7d21

@JaKXz
Copy link
Member

JaKXz commented Jan 24, 2019

I think this has been fixed in v13+. I'll leave this open for now to be confirmed

@istanbuljs istanbuljs deleted a comment from stale bot Jan 24, 2019
@JaKXz JaKXz removed the wontfix label Jan 24, 2019
@coreyfarrell
Copy link
Member

Closing this as nyc 12.0.0 dropped support for node.js 4, see the CHANGELOG.md for nyc@12.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants