question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:29 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
JeffMLcommented, Dec 18, 2017

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.

0reactions
stale[bot]commented, May 12, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Command-line usage - mocha - w3resource
Non-compliant tests are marked as failures. #--bail, -b. This will cause Mocha to stop running tests after the first test failure it encounters....
Read more >
Mocha - the fun, simple, flexible JavaScript test framework
simple, flexible, fun. Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun....
Read more >
node.js - Mocha isn't displaying any details for failed tests
Turns out that Mocha is fine and my test definitions are fine, I had simply fixed a totally different migration issue incorrectly.
Read more >
Mocha - API Manual
Mocha tests run serially, allowing for flexible and accurate reporting, ... you to use any assertion library you want, if it throws an...
Read more >
How To Test a Node.js Module with Mocha and Assert
Testing is an integral part of software development. It's common for programmers to run code that tests their application as they make changes ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found