Skip to content

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

@kristianmandrup

Description

@kristianmandrup

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 ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions