Skip to content
This repository has been archived by the owner on Dec 31, 2019. It is now read-only.

Babel 6 Support #81

Closed
spudly opened this issue Oct 30, 2015 · 60 comments
Closed

Babel 6 Support #81

spudly opened this issue Oct 30, 2015 · 60 comments

Comments

@spudly
Copy link

spudly commented Oct 30, 2015

Can't run tests under a project that uses babel 6 because isparta depends on babel 5...

@douglasduteil
Copy link
Owner

Hi @spudly
I will spend some time on it tomorrow.

@tleunen
Copy link

tleunen commented Nov 1, 2015

It doesn't require much work I think to upgrade the version, but some tests could fail because of Babel known issues. (class properties are one of them for example)

@mikeallisonJS
Copy link

one issue I'm seeing is .babelrc presets flag blowing up. Thanks for your assistance and work!

@ghaiklor
Copy link

ghaiklor commented Nov 2, 2015

Trying to run tests and getting the next error

Transformation error; return original code
[ReferenceError: [BABEL] /Users/ghaiklor/Library/Projects/passport-amazon-token/src/index.js: Unknown option: /Users/ghaiklor/Library/Projects/passport-amazon-token/.babelrc.presets]

@spudly
Copy link
Author

spudly commented Nov 2, 2015

The presets warning is shown because isparta depends on [email protected], which doesn't have a presets option.

@mikeallisonJS
Copy link

testing my fork shortly. hopefully I'll have a PR for you before long

@mikeallisonJS
Copy link

eh.... it's building, but failing tests. feel free to take a look, hopefully my work can help you along.

@tleunen
Copy link

tleunen commented Nov 2, 2015

What are the errors? Did you try to remove the es6 classes tests?

@tleunen
Copy link

tleunen commented Nov 3, 2015

Hmm I just tried and got this error, but no idea where it comes from.

Invariant Violation: To get a node path the parent needs to exist

@mikeallisonJS
Copy link

Ok, I think I have it ready, but it looks like:
export * from
is broken in babel6 currently.
Otherwise I think my fork is nearly ready.

@douglasduteil
Copy link
Owner

Great @mikeallisonJS 👍
I know I opened an issue about that babel/babel#2763

@nathancahill
Copy link

Here's what I'm seeing with Babel 6.0.15

.babelrc:

{
  "presets": ["es2015"]
}
$ babel-node ./node_modules/.bin/isparta cover _mocha
Transformation error; return original code
[ReferenceError: [BABEL] src/lib.js: Unknown option: .babelrc.presets]

No coverage information was collected, exit without writing coverage information

If I remove the presets options from .babelrc, and use the command line option, everything works:

$ babel-node --presets es2015 ./node_modules/.bin/isparta cover _mocha
Transformation error; return original code
{ [Error: Line 1: Unexpected token ILLEGAL]
  lineNumber: 1,
  description: 'Unexpected token ILLEGAL',
  index: 0 }

=============================== Coverage summary ===============================
Statements   : 100% ( 138/138 ), 10 ignored
Branches     : 98.61% ( 71/72 ), 9 ignored
Functions    : 100% ( 12/12 )
Lines        : 100% ( 69/69 )
================================================================================

@jednano
Copy link
Contributor

jednano commented Nov 4, 2015

@nathancahill do you know why it says 10 ignored statements and 9 ignored branches? I've been having similar issues, but I don't have any ignore comments in my code. Do you?

@nathancahill
Copy link

I don't @jedmao. I double checked the coverage, and it seems to be working correctly. :shrugs:

@nathancahill
Copy link

@mikeallisonJS, I picked up where you left off with the export * bug in Babel. I hacked around it by enumerating the exports from Istanbul: d98dbba

Tests are running, it looks like some numbers in the ES6 classes are different than expected, but not too far off.

@douglasduteil
Copy link
Owner

@nathancahill
Copy link

Cool, submitted #88. Besides the export * bug, even once that is fixed, it looks like the exports can not be overriden, like Instrumenter and VERSION. AFAIK, properties on the export object are set with configurable=false so they can't be deleted or changed. So we might have to export specific symbols anyway.

@nkbt
Copy link

nkbt commented Nov 7, 2015

For export stuff you need to use babel-plugin-transform-es2015-modules-commonjs. It is not included into presets. And it is not a bug

@nkbt
Copy link

nkbt commented Nov 7, 2015

Ah sorry, I see you are using stage-0, so it is included.

My workaround was not to use global babel config at all for the moment and let isparta use babel5, but rest uses babel6.

Scripts get a bit ugly though (since I heed to pass parameters manually)

"babel-node": "babel-node --presets es2015,react --plugins transform-es2015-modules-commonjs,transform-object-rest-spread",
"test:cov": "npm run babel-node -- node_modules/isparta/bin/isparta cover --report text --report html --dir reports/coverage --include \"**/!(*-test).js\" test",

20151107-214001

@gregberge
Copy link
Contributor

Can we expect an update soon? 😅

@gregberge
Copy link
Contributor

@douglasduteil @nkbt a working PR #90

@tleunen
Copy link

tleunen commented Nov 15, 2015

Thanks @douglasduteil, seems to work fine.

@iamstarkov
Copy link

isparta is not working for me, as before =(

@iamstarkov
Copy link

No coverage information was collected, exit without writing coverage information
https://travis-ci.org/iamstarkov/domain-links/jobs/91499048#L507
https://github.com/iamstarkov/domain-links/blob/master/package.json#L7

@iamstarkov
Copy link

the same lines are working fine with babel v5 and isparta v3

@nkbt
Copy link

nkbt commented Nov 17, 2015

@iamstarkov are you sure that --require babel-core/register uses babel6 too and does not fail somewhere on the way?

@iamstarkov
Copy link

I'm sure because mocha is working fine with that, take a look at npm test script and its output in travis

@iamstarkov
Copy link

@nkbt how do you use isparta with babel v6 with mocha?

@Dakuan
Copy link

Dakuan commented Nov 17, 2015

@iamstarkov I am also having the same issues. Worked fine with babel 5 and isparta v3.

Mocha is running the tests just fine on its own

@Dakuan
Copy link

Dakuan commented Nov 17, 2015

  babel-node ./node_modules/.bin/isparta cover --verbose  --root './src' --include '**/*.es6' --include '**/*.jsx' --include '**/*.js' --report json-summary --report lcov _mocha -- --recursive --compilers es6:babel-core/register
Loading config: /Users/Dom/git/energy-scanner-web/.istanbul.yml
Using configuration
-------------------
verbose: true
instrumentation:
    root: ./src
    extensions:
        - .jsx
        - .js
        - .es6
    default-excludes: true
    excludes: []
    embed-source: false
    variable: __coverage__
    compact: true
    preserve-comments: false
    complete-copy: false
    save-baseline: false
    baseline-file: ./coverage/coverage-baseline.json
    include-all-sources: false
    include-pid: false
    preload-sources: false
reporting:
    print: summary
    reports:
        - json-summary
        - lcov
    dir: ./coverage
    watermarks:
        statements: [50, 80]
        lines: [50, 80]
        functions: [50, 80]
        branches: [50, 80]
    report-config:
        clover: {file: clover.xml}
        cobertura: {file: cobertura-coverage.xml}
        json: {file: coverage-final.json}
        json-summary: {file: coverage-summary.json}
        lcovonly: {file: lcov.info}
        teamcity: {file: null, blockName: Code Coverage Summary}
        text: {file: null, maxCols: 0}
        text-lcov: {file: lcov.info}
        text-summary: {file: null}
hooks:
    hook-run-in-context: false
    post-require-hook: null
    handle-sigint: false
check:
    global:
        statements: 0
        lines: 0
        branches: 0
        functions: 0
        excludes: []
    each:
        statements: 0
        lines: 0
        branches: 0
        functions: 0
        excludes: []

-------------------

Isparta options :
  { '0': 'cover',
  '--': [ '--recursive', '--compilers', 'es6:babel-core/register' ],
  verbose: true,
  root: './src',
  include: [ '**/*.es6', '**/*.jsx', '**/*.js' ],
  report: [ 'json-summary', 'lcov' ],
  cmd: '_mocha',
  _: [ 'cover', '_mocha' ],
  excludes: [] }
Running: node /usr/local/bin/_mocha --recursive --compilers es6:babel-core/register


  API
    GET /
::ffff:127.0.0.1 - GET /api/ HTTP/1.1 200 13 - 3.871 ms
      ✓ should return 200 (39ms)

  app
    GET /
Warning: missing space before text for line 12 of jade file "/Users/Dom/git/energy-scanner-web/src/server/app/views/index.jade"
      ✓ should return 200 (532ms)

  two
    ✓ should work


  3 passing (694ms)

No coverage information was collected, exit without writing coverage information

@nkbt
Copy link

nkbt commented Nov 17, 2015

I use Tape and do not use Mocha. No overhead of testing framework, no problems ;)

@iamstarkov
Copy link

le sigh

@joseluisq
Copy link

Cool ! 👍

@Dakuan
Copy link

Dakuan commented Nov 18, 2015

as this might be mocha specific shall I open a new issue @douglasduteil ?

@douglasduteil
Copy link
Owner

Yep

@douglasduteil
Copy link
Owner

@Dakuan yep please. Do you have the same problem ? Did you consult my demo here https://github.com/douglasduteil/study-node-path-es6 ?

@Dakuan
Copy link

Dakuan commented Nov 18, 2015

@douglasduteil @iamstarkov

Had a look at the study project and have fixed my build :)

The trick was adding --include-all-sources. This wasn't required for isparta 3, but apparently is now.

Thanks for the pointer.

@iamstarkov
Copy link

yep, its working now

"coverage": "isparta cover _mocha index.js --include-all-sources -- --require babel-core/register",

@iamstarkov
Copy link

but one pretty big downside, that it includes all files even i explicitly say to cover only index.js

@iamstarkov
Copy link

screen shot 2015-11-18 at 11 47 19

@Dakuan
Copy link

Dakuan commented Nov 18, 2015

tell a lie, it's all gone to shit on my CI server. Clearing all my npm stuff has brought it all down:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'ci' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'preci', 'ci', 'postci' ]
5 info preci [email protected]
6 info ci [email protected]
7 verbose unsafe-perm in lifecycle true
8 info [email protected] Failed to exec ci script
9 verbose stack Error: [email protected] ci: `npm run lint && npm test`
9 verbose stack Exit status 1
9 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:214:16)
9 verbose stack     at emitTwo (events.js:87:13)
9 verbose stack     at EventEmitter.emit (events.js:172:7)
9 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:24:14)
9 verbose stack     at emitTwo (events.js:87:13)
9 verbose stack     at ChildProcess.emit (events.js:172:7)
9 verbose stack     at maybeClose (internal/child_process.js:818:16)
9 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
10 verbose pkgid [email protected]
11 verbose cwd /Users/Dom/git/energy-scanner-web
12 error Darwin 15.0.0
13 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "ci"
14 error node v4.2.2
15 error npm  v2.14.7
16 error code ELIFECYCLE
17 error [email protected] ci: `npm run lint && npm test`
17 error Exit status 1
18 error Failed at the [email protected] ci script 'npm run lint && npm test'.
18 error This is most likely a problem with the energy-scanner-web package,
18 error not with npm itself.
18 error Tell the author that this fails on your system:
18 error     npm run lint && npm test
18 error You can get their info via:
18 error     npm owner ls energy-scanner-web
18 error There is likely additional logging output above.
19 verbose exit [ 1, true ]

@Dakuan
Copy link

Dakuan commented Nov 18, 2015

> [email protected] test /Users/Dom/git/energy-scanner-web
> npm run clean && NODE_ENV=test babel-node ./node_modules/.bin/isparta cover -i './**/*.es6' -i './**/*.jsx' -i './**/*.js' --include-all-sources --report json-summary --report lcov _mocha -- --recursive --compilers es6:babel-core/register


> [email protected] clean /Users/Dom/git/energy-scanner-web
> rm -rf coverage

npm ERR! Test failed.  See above for more details.

npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "ci"
npm ERR! node v4.2.2
npm ERR! npm  v2.14.7
npm ERR! code ELIFECYCLE
npm ERR! [email protected] ci: `npm run lint && npm test`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] ci script 'npm run lint && npm test'.
npm ERR! This is most likely a problem with the energy-scanner-web package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run lint && npm test
npm ERR! You can get their info via:
npm ERR!     npm owner ls energy-scanner-web
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/Dom/git/energy-scanner-web/npm-debug.log

@nkbt
Copy link

nkbt commented Nov 18, 2015

I'm not quite sure what sort of issues you have, logs are not very helpful.

My projects do not have issues with isparta4/babel6

https://circleci.com/gh/nkbt/react-component-template/148

See this block:

./node_modules/.bin/babel-node ./node_modules/.bin/isparta cover --report text --report lcov --verbose --dir ${CIRCLE_ARTIFACTS}/coverage --include '**/!(*-test).js' 

And coverage looks ok as usual.

https://coveralls.io/builds/4189818

@iamstarkov
Copy link

@douglasduteil can you help us with mocha framework?

@nathancahill
Copy link

@iamstarkov, here's what I'm doing with mocha:

./node_modules/.bin/babel-node ./node_modules/.bin/isparta cover ./node_modules/.bin/_mocha

Here's the latest build with coverage output: https://travis-ci.org/nathancahill/eminent

My .istanbul.yml:

instrumentation:
  root: src

@playground
Copy link

@nkbt I'm using tape 4.6.2 and "isparta": "^4.0.0" and I'm still getting
No coverage information was collected, exit without writing coverage information
Can you show me how you get it to work?

@iamstarkov
Copy link

@playground try nyc

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

No branches or pull requests