Better errors - #97
Conversation
julianrubisch
left a comment
There was a problem hiding this comment.
Sorry it took so long. There's only one typo and a documentation request 😄
|
|
||
| private | ||
|
|
||
| def error_render |
There was a problem hiding this comment.
| def error_render | |
| def error_renderer |
There was a problem hiding this comment.
Good point. I'm happy to correct this in the next day or two, assuming you're ok with the assert_cable_ready_operation_on extraction.
There was a problem hiding this comment.
I'm fine with it! Let's hear what the others say.
| end | ||
| end | ||
|
|
||
| def assert_cable_ready_operation_on(stream, operation:, selector:, html:, &block) |
There was a problem hiding this comment.
Do you have a link to the respective docs and/or further explanation for me?
TBH it's hard to grok what's going on with broadcasts and clear_messages etc., and it's hard to see why this preferable to the original, simpler assert_broadcast_on
There was a problem hiding this comment.
Totally get the confusion -- I honestly don't know what it's mostly doing. This is a copy-paste job from https://github.com/rails/rails/blob/5aaaa1630ae9a71b3c3ecc4dc46074d678c08d67/actioncable/lib/action_cable/test_helper.rb#L97
With then a slight modification to build the cable-ready payload. If this style of thing works, I think extracting this to its own file (happy to do so now), and ideally extract to a gem or really just including in https://github.com/hopsoft/cable_ready might be warranted. The API would need to be cleaned up to support multiple message broadcasts and such, but could be helpful to the community.
There was a problem hiding this comment.
Ah okay, now I get it. Yep, that makes sense. I do think that it would make sense to have this in CR, e.g. to help out here: https://github.com/hopsoft/stimulus_reflex/blob/master/test/broadcasters/page_broadcaster_test.rb#L41
Ping @leastbad @marcoroth @hopsoft
There was a problem hiding this comment.
I am no testing expert, but I can say that very recently I found myself copy-pasting the assert_broadcast_on method into the test class (temporarily!) so that I could redefine the method with a puts in there to spit out what the assert was expecting so I could tweak the data structure hard-coded into the test and make it pass. eg the functionality was working but the test was off by "this much"
I would love to see CR redefine assert_broadcast_on to also print out (puts) the value it's expecting.
Type of PR (feature, enhancement, bug fix, etc.)
Description
In development and test, we render a short version of the error message (and a hidden backtrace) to be able to catch typos, bugs in our partials, etc.
Fixes #63
Why should this be added
While developing you're not often watching the logs to see what's happening. This will output a fairly obvious error message and the backtrace is hidden (via
display: none;Checklist