test-results-reporter / parser

Parse test results from JUnit, TestNG, xUnit and many more
https://www.testbeats.com
MIT License
12 stars 9 forks source link

Feature: skipped_tests_passed flag for mocha parser #65

Closed jmuleiro closed 2 months ago

jmuleiro commented 4 months ago

Context

I have a few tests that are skipped via feature flags that are evaluated in Cypress' code. Because of what the resulting JSON looks like, the parser interprets the results as if passed tests < total tests. Though this is technically correct, because the tests themselves didn't run, you can't exactly say they failed (or passed, for that matter). But with my use case, I need those skipped tests to be ignored and not considered for the pass rate.

Because this feels like such a niche scenario, I decided to implement flag into the parser's configuration, that would look like this in testbeats' configuration:

{
  "results": [
    {
      "type": "mocha",
      "files": ["cypress-output.json"],
      "skipped_tests_passed": true
    }
  ]
}

The flag, set to false by default, lets the mocha parser completely ignore skipped and pending tests, subtracting them from the total metric, which leads to testbeats showing an appropriate pass rate (of 100% in my case).

Changes

jmuleiro commented 4 months ago

Note: Feel free to suggest a better name for the flag, skipped_tests_passed was the best I could come up with. Note 2: I'm using a custom-built version of the packages in the meantime, so there's no rush to get this feature in from my end.

ASaiAnudeep commented 3 months ago

I believe this is something mocha reporter should support natively.

jmuleiro commented 3 months ago

I believe this is something mocha reporter should support natively.

@ASaiAnudeep I agree, though for the time being, it doesn't.

ASaiAnudeep commented 2 months ago

Closing this as for now. Will come up with a better way to handle extensions.