newman-reporter-html icon indicating copy to clipboard operation
newman-reporter-html copied to clipboard

Implemented --reporter-html-no-success-assertions

Open jimc404 opened this issue 4 years ago • 2 comments

Fixes postmanlabs/newman#1902

What does this PR do?

It allows the user to suppress successful assertions by passing the flags --reporter-html-no-success-assertions while using the newman cli or if using the library setting the key noSuccessAssertions to true

Implementation:

  • Changes were made at the end of beforeDone event. This is was done so that there is no change on calculation and aggregation of stats.
  • If noSuccessAssertions option is present, traverse the executions and each assertion in them.
  • Filter the assertion array by removing the assertions having failed=0. This will be the new assertion array

Here I removed the assertions which have failed=0 rather than something like passed=1. This is done to account for the case when multiple assertions have the same description. Assertions are tracked using their description as a key, so ones with same description will be counted together and may be omitted if we check through the value ofpassed .

Testing:

In test/integration/library.test.js I have added 2 tests each for CLI and library. They check for suppression of assertions when failing cases as present and when they are not. Since the output is deterministic (as the default template is used) I directly matched the string for presence of the assertion table.

jimc404 avatar Feb 28 '20 16:02 jimc404

I went the simple way and added the tests which directly reading HTML as a string and match sub-strings. It seemed to be the lighter alternative compared to using HTML parsing when the output is already deterministic.

jimc404 avatar Feb 29 '20 17:02 jimc404

@codenirvana I have made the changes for no-success-assertions to the right repo. You can review them

jimc404 avatar Mar 02 '20 13:03 jimc404