ValentinH / jest-fail-on-console

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

Support for callback function to skip tests #26

Closed lws803 closed 2 years ago

lws803 commented 2 years ago

Addition of a skipTest callback function param which provides a higher degree of customization to determine if a test should be skipped or not.

this could potentially make the skipTestNames param redundant earlier but I'd leave it there for backwards compatibility just in case someone has already started using it 👍

ValentinH commented 2 years ago

There is already a silenceMessage function, could it provide what you need? Otherwise, it could be nice to extend it to match your needs.

lws803 commented 2 years ago

There is already a silenceMessage function, could it provide what you need?

Unfortunately not :x since silenceMessage works for skipping specific error messages like:

Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

which is pretty generic and happens across multiple test suites 😄 we're trying to ignore only specific files and not for all error messages of that kind

Otherwise, it could be nice to extend it to match your needs.

Not too sure if they're the same thing though 🤔 since silencing messages are used for silencing messages from the error message output. I would extend skipTest to include the ability to silence messages as well (instead of extending on silenceMessage param) to make it more generic but I'll leave that to your discretion 👍

ValentinH commented 2 years ago

Ok I get your point. Let's keep like this. However I would remove the skipTestNames option. I have no issue with bumping a major release to be safe.

One last thing, could you add one test case for th renew option please?

lws803 commented 2 years ago

Ok I get your point. Let's keep like this. However I would remove the skipTestNames option. I have no issue with bumping a major release to be safe.

One last thing, could you add one test case for th renew option please?

Added as of previous 2 commits 😄

lws803 commented 2 years ago

Hey @ValentinH any word on reviewing this PR? 😄 Just wanted to make sure it wasn't forgotten, no rush if you're busy atm 👍

ValentinH commented 2 years ago

I'll merge this on Monday. Sorry for the delay .

ValentinH commented 2 years ago

Released as https://github.com/ValentinH/jest-fail-on-console/releases/tag/v3.0.0 🚀

lws803 commented 2 years ago

Released as https://github.com/ValentinH/jest-fail-on-console/releases/tag/v3.0.0 🚀

Yayy thank you! 🙌