Allow hiding assertion logs for `.should()` and `.and()` except on failure
See original GitHub issueCurrent behavior:
There is no way to hide logs when making assertions, for example, with should
.
Desired behavior:
There is a way to hide passing assertions while still reporting failing assertions. Ideally these successful assertions could also be turned back on when running under a different log level.
This came up because I wanted a “safer” version of the get
command, which would by default assert that there is only 1 element found (unless an explicit length
option was passed) and that the element is visible (unless an explicit noVisibleCheck
option was passed), since I’ve seen tests fail or falsely succeed because of overbroad selectors or when an element was present in the DOM but not visible. Cypress tests run fast enough that doing this shouldn’t add significantly to the test run time.
However, when I do this, I end up with a ton of extra logs for each get
, which clutters the test output. I’d like a way to disable these logs by default, unless the assertions fail.
Test code to reproduce
https://github.com/ncknuna/cypress-test-tiny/blob/master/cypress/support/commands.js#L45
Versions
Cypress 4.8.0 OSX 10.15.5 Chrome 83.0.4103.61
Issue Analytics
- State:
- Created 3 years ago
- Reactions:40
- Comments:27 (2 by maintainers)
Top GitHub Comments
I would like this feature as well, to only log assertions that fail.
As a workaround for assertions that are easily checked up front, you can use a somewhat redundant approach like:
+1
I like to check that a cookie exists before each outgoing api request & suppressing this assertion would clean up test logs quite nicely 👍