ValentinH / jest-fail-on-console

Utility to make jest tests fail when console.error() or any other methods are used
MIT License
141 stars 20 forks source link

Support for `groupCollapsed`/`groupEnd` #36

Closed lennym closed 1 year ago

lennym commented 1 year ago

Where console calls are wrapped in a console.groupCollapsed it would be good to have the group heading included in the message passed to silenceMessage.

In our case we use recoil which console.warns arbitrary objects collapsed with a predictable header. We'd like to be able to use this header to ignore the warnings rather than having to remove fail-on-warn completely.

I'd imagine passing any group context as an additional argument to silenceMessage would be reasonably straightforward. Happy to put together a PR if required.

ValentinH commented 1 year ago

I didn't know this group feature. I'd be happy to review a PR. 😊

lennym commented 1 year ago

Thanks. We'll likely put together a PR in the next few days.

Are you broadly happy with the approach to add additional context as a third parameter to silenceMessage?

ValentinH commented 1 year ago

Yes I'm ok with this. I hesitated to do a breaking change and switch to a single object argument but I'm not sure it's worth the hassle.

lennym commented 1 year ago

Agreed. Probably worth doing if you ever go to v4 anyway, but this feels like a pretty niche feature, so not worth a v4 on its own.

ValentinH commented 1 year ago

Fixed by #37 and published as https://github.com/ValentinH/jest-fail-on-console/releases/tag/v3.1.0