mochawesome: Use `mocha --opts` command to run tests, it is fail to genarate the report when assert fail

1.The test suite :

var assert = require("chai").assert;

describe("# Hello, world!", function () {
    it("1+1=2",function(){
        assert.equal(1+1,3);
        assert.ok('Hello, world!');
    })
});

2.mocha.opts :

--reporter mochawesome
--reporter-options reportDir=mochawesome-report,reportFilename=mocha-helloworld,reportTitle=mocha-helloworld,reportPageTitle="Helloworld-Report",overwrite=true
--timeout 200

3.run mocha command

>mocha --opts mocha.opts
  1. it is fail to genarate the report
  ## Hello, world!
    1) 1+1=2

  ## mysql test
undefined
    √ query (144ms)

  ## https://www.github.com
    2) github


  1 passing (385ms)
  2 failing

image

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 29 (8 by maintainers)

Most upvoted comments

Had another test box (Mac OS) where this was failing to generate reports. Go it working, but still not quite sure how. Things I did:

  1. upgraded my npm from 2.3.x to 2.15.x
  2. removed and reinstalled mocha and mochawesome, --save-dev
  3. removed and reinstall mocha globally (–save)

Before this, when I ran mocha from the command line, it would not find the mochawesome reporter; now it does (mocha tests/bugTest.js --reporter mochawesome). If I run ‘npm test’, it works. If I try ‘npm run test’, I get the ELIFECYCLE error mentioned in previous comment.

That’s kind of a mess of clues, but if you revert to an earlier instance of npm, then remove and reinstall mocha, I bet you can reproduce this.