newman-reporter-html
newman-reporter-html copied to clipboard
Implemented --reporter-html-no-success-assertions
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.
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.
@codenirvana I have made the changes for no-success-assertions to the right repo. You can review them