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

Problem with silent fail and using coveralls + mocha-webpack #433

Closed
kristianmandrup opened this issue Nov 1, 2016 · 2 comments
Closed

Comments

@kristianmandrup
Copy link

I have this setup

"scripts:" {
    "mocha:lint:test": "npm run lint & mocha-webpack --opts test/config/mocha/mocha-webpack.opts",
    "mocha:test": "mocha-webpack --opts test/config/mocha/mocha-webpack.opts",
    "mocha:test:watch": "mocha-webpack --opts test/config/mocha/mocha-webpack.opts --watch",
    "test": "npm run mocha:test --silent",
    "coverage": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text --cache --silent mocha-webpack --opts test/config/mocha/mocha-webpack.opts",
    "coveralls": "npm run coverage | coveralls",
    "istanbul": "npm-run istanbul cover",
    "cover:report": "npm-run plato -r -d report src",
   ...
}

First problem is that I get this stupid Exit 1 error each time.

 0 passing (14ms)
  1 failing

  1) Operator: code an instance have a name:
     AssertionError: expected { opts: 'kris' } to deeply equal true
      at Context.that.should (eval at <anonymous> (.tmp/mocha-webpack/28cf7d614cc45dc0abdbbfe10ec37561/28cf7d614cc45dc0abdbbfe10ec37561-output.js:85:1), <anonymous>:17:32)


npm ERR! Darwin 16.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "coverage"
npm ERR! node v7.0.0
npm ERR! npm  v4.0.1
npm ERR! code ELIFECYCLE
npm ERR! code-operator-js@1.0.0 coverage: `cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text --cache --silent mocha-webpack --opts test/config/mocha/mocha-webpack.opts`
npm ERR! Exit status 1

I was successful adding silent mode here:

"test": "npm run mocha:test --silent", how can I do the same for my coverage script?

Second, when I pipe to coveralls it fails:

 cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text --cache --silent mocha-webpack --opts test/config/mocha/mocha-webpack.opts | coveralls

[error] "2016-11-01T19:39:31.511Z"  'error from lcovParse: ' 'Failed to parse string'
[error] "2016-11-01T19:39:31.513Z"  'input: ' '\n\n\u001b[0m\u001b[0m\n\u001b[0m  Operator: code\u001b[0m\n\u001b[0m    an instance\u001b[0m\n    \u001b[31m  1) have a name\u001b[0m\n\n\n\u001b[92m \u001b[0m\u001b[32m 0 passing\u001b[0m\u001b[90m (16ms)\u001b[0m\n\u001b[31m  1 failing\u001b[0m\n\n\u001b[0m  1) Operator: code an instance have a name:\n\u001b[0m\u001b[31m     AssertionError: expected { opts: \'kris\' } to deeply equal true\u001b[0m\u001b[90m\n      at Context.that.should (eval at <anonymous> (.tmp/mocha-webpack/28cf7d614cc45dc0abdbbfe10ec37561/28cf7d614cc45dc0abdbbfe10ec37561-output.js:85:1), <anonymous>:17:32)\n\u001b[0m\n\n\n'
[error] "2016-11-01T19:39:31.513Z"  'error from convertLcovToCoveralls'

/Users/kristianmandrup/repos/node-libs/code-operator/node_modules/coveralls/bin/coveralls.js:18
        throw err;
        ^
Failed to parse string

npm ERR! Darwin 16.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "coverage"
npm ERR! node v7.0.0
npm ERR! npm  v4.0.1
npm ERR! code ELIFECYCLE
npm ERR! code-operator-js@1.0.0 coverage: `cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text --cache --silent mocha-webpack --opts test/config/mocha/mocha-webpack.opts | coveralls`
npm ERR! Exit status 1

Since it tries to parse the output from running the mocha tests via mocha-webpack.
What is the right way? To run it using mocha and sidestepping webpack!?

Thanks ;)

@kristianmandrup
Copy link
Author

I get the same problems with this setup:

    "coverage": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text --cache mocha src/**/*.test.js",
    "coveralls": "npm run coverage | coveralls",

Please advice :)

@bcoe
Copy link
Member

bcoe commented Nov 13, 2016

@kristianmandrup coveralls needs to have lcov format pushed at it, I recommend using this approach instead:

    "coverage": "cross-env NODE_ENV=test nyc --reporter=text --cache mocha src/**/*.test.js",
    "coveralls": "nyc report --reporter=text-lcov | coveralls",

As long as you run coverage before running coveralls, nyc will have cached the coverage data; and will be able to run a text-lcov report that you can pipe to coveralls.

Feel free to reopen this issue if this doesn't do the trick for you.

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

2 participants