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.

Incorrect report data when mocha retries enabled

See original GitHub issue

When we run tests with mocha retries enabled and a test fails the suites data generated in the report shows that the test was skipped instead of failed (all other properties of the report correctly show it as having failed).

This results in the .html page looking like (with no ability to change the toggles to show the failing tests): image

I know this isn’t a lot of information, so I’m happy to provide whatever else would make this easier to track down. Below is an example of the issue (file name and titles have been altered).

{
  "stats": {
    "suites": 1,
    "tests": 1,
    "passes": 0,
    "pending": 0,
    "failures": 1,
    "start": "2017-09-18T23:16:56.175Z",
    "end": "2017-09-18T23:17:27.574Z",
    "duration": 31399,
    "testsRegistered": 1,
    "passPercent": 0,
    "pendingPercent": 0,
    "other": 0,
    "hasOther": false,
    "skipped": 0,
    "hasSkipped": false,
    "passPercentClass": "danger",
    "pendingPercentClass": "danger"
  },
  "suites": {
    "title": "",
    "suites": [
      {
        "title": "suite title 1",
        "suites": [],
        "tests": [
          {
            "title": "suite title 1",
            "fullTitle": "suite title 1",
            "timedOut": false,
            "duration": 9101,
            "pass": false,
            "fail": false,
            "pending": false,
            "code": "step(\"throw\", err); }); } } return step(\"next\"); });",
            "err": {},
            "isRoot": false,
            "uuid": "31b95db9-7879-4785-aab7-6d493d6a7edb",
            "parentUUID": "26fe76b2-d17f-4272-a04f-249eaaf602ba",
            "isHook": false,
            "skipped": true
          }
        ],
        "pending": [],
        "root": false,
        "_timeout": 480000,
        "file": "filename.js",
        "uuid": "26fe76b2-d17f-4272-a04f-249eaaf602ba",
        "beforeHooks": [
          {
            "title": "\"before all\" hook: checkNemo",
            "fullTitle": "title",
            "timedOut": false,
            "duration": 14694,
            "pass": false,
            "fail": false,
            "pending": false,
            "code": "function checkNemo(_done) {\n        Nemo(config).then(function (_nemo) {\n          nemo = _nemo;\n          _done();\n        }).catch(function (err) {\n          error(err);\n          _done(err);\n          if (done) {\n            done(result);\n          }\n        });",
            "err": {},
            "isRoot": false,
            "uuid": "c7d50765-ad88-4929-8794-ebc57fb2bf4e",
            "parentUUID": "26fe76b2-d17f-4272-a04f-249eaaf602ba",
            "isHook": true,
            "skipped": false
          }
        ],
        "afterHooks": [],
        "fullFile": "title",
        "passes": [],
        "failures": [],
        "skipped": [
          {
            "title": "test title 1",
            "fullTitle": "test title 1",
            "timedOut": false,
            "duration": 9101,
            "pass": false,
            "fail": false,
            "pending": false,
            "code": "step(\"throw\", err); }); } } return step(\"next\"); });",
            "err": {},
            "isRoot": false,
            "uuid": "31b95db9-7879-4785-aab7-6d493d6a7edb",
            "parentUUID": "26fe76b2-d17f-4272-a04f-249eaaf602ba",
            "isHook": false,
            "skipped": true
          }
        ],
        "hasBeforeHooks": true,
        "hasAfterHooks": false,
        "hasTests": true,
        "hasSuites": false,
        "totalTests": 1,
        "totalPasses": 0,
        "totalFailures": 0,
        "totalPending": 0,
        "totalSkipped": 1,
        "hasPasses": false,
        "hasFailures": false,
        "hasPending": false,
        "hasSkipped": true,
        "duration": 9101,
        "rootEmpty": false
      }
    ],
    "tests": [],
    "pending": [],
    "root": true,
    "_timeout": 480000,
    "uuid": "c37788b8-0b57-4907-ad4f-cd20eb894244",
    "beforeHooks": [],
    "afterHooks": [],
    "fullFile": "",
    "file": "",
    "passes": [],
    "failures": [],
    "skipped": [],
    "hasBeforeHooks": false,
    "hasAfterHooks": false,
    "hasTests": false,
    "hasSuites": true,
    "totalTests": 0,
    "totalPasses": 0,
    "totalFailures": 0,
    "totalPending": 0,
    "totalSkipped": 0,
    "hasPasses": false,
    "hasFailures": false,
    "hasPending": false,
    "hasSkipped": false,
    "duration": 0,
    "rootEmpty": true
  },
  "allTests": [
    {
      "title": "test title 1",
      "fullTitle": "test title 1",
      "timedOut": false,
      "duration": 7520,
      "state": "failed",
      "pass": false,
      "fail": true,
      "pending": false,
      "code": "step(\"throw\", err); }); } } return step(\"next\"); });",
      "err": {
        "message": "StatusCodeError: 500",
        "estack": "StatusCodeError: 500"
      },
      "isRoot": false,
      "uuid": "7f797ca2-a693-4233-8e07-8cbb1fe9a3be",
      "parentUUID": "26fe76b2-d17f-4272-a04f-249eaaf602ba",
      "isHook": false,
      "skipped": false
    }
  ],
  "allPending": [],
  "allPasses": [],
  "allFailures": [
    {
      "title": "test title 1"",
      "fullTitle": "test title 1",
      "timedOut": false,
      "duration": 7520,
      "state": "failed",
      "pass": false,
      "fail": true,
      "pending": false,
      "code": "step(\"throw\", err); }); } } return step(\"next\"); });",
      "err": {
        "message": "StatusCodeError: 500",
        "estack": "StatusCodeError: 500"
      },
      "isRoot": false,
      "uuid": "7f797ca2-a693-4233-8e07-8cbb1fe9a3be",
      "parentUUID": "26fe76b2-d17f-4272-a04f-249eaaf602ba",
      "isHook": false,
      "skipped": false
    }
  ],
  "copyrightYear": 2017
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
adamgrubercommented, Sep 19, 2017

The only alternative I’ve thought about is to not use the suite end event to generate the report data and instead listen to each test event and build out the data that way since retries will emit events same as any other test. It feels like a pretty big undertaking to fundamentally change how mochawesome gets its data. I could be wrong though and maybe its not as involved as I think.

0reactions
adamgrubercommented, Feb 2, 2018

Duplicate of #125

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mocha - the fun, simple, flexible JavaScript test framework
Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun.
Read more >
Command-line usage - mocha - w3resource
This behavior will enable a set of potential problems; it's indicative of tests (or fixtures, harnesses, code under test, etc.) that don't clean ......
Read more >
retry failed mocha test - Stack Overflow
I have some requirement that demands to retry mocha failure tests multiple times. Is there any easy way/workaround to do this?
Read more >
Reporters | Cypress Documentation
cypress-multi-reporters : enables multiple reporters; mocha-junit-reporter the actual junit reporter, as we cannot use the junit reporter that comes with ...
Read more >
10 Mocha.js Best Practices - CLIMB
Mocha is a great JavaScript testing framework, but there are a few ... It is a feature-rich library that enables developers to write...
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