betterer
betterer copied to clipboard
Feature Request: Custom Failure Messages
When adding custom rules, it would be nice to be able to customize the output when the rule fails. The use case is that I made a rule counting import cycles, and I want to be able to print a link about how to fix an import cycle if CI fails. If there's a way to do this already that I missed, please let me know!
I'm happy to work on adding this feature, if that's appropriate. I'm guessing it would start with a new (optional) property on BettererTestOptionsComplex?
So it's not the clearest API because I want to limit what is exposed publicly, but you should be able to provide a custom differ function as part of your test, and the return value of the differ can include a set of logs that will be printed.
Thanks for your help! A couple questions:
- It looks like the 'diff' property that the differ returns is only used by file tests and the VS Code extension. Is that right?
- It looks like logs are only used if a test got worse or was force updated. That would mean there's no way for a non-file test to log a progress message when it improves. Is that right?
- If I understand 2. right, would a PR adding diff logging to the 'isBetter' case here be welcome? Or is this a 'make your own reporter' kind of thing?
I'm going to close this, because existing functionality covered what we really wanted. Being able to customize the 'made progress' log was more of a nice-to-have.
Thanks for making this project! It's bettering my life 😄 .
Gonna reopen it so I remember to look at it ❤️
Glad you're liking it, let me know if I can help with anything!