Bug 27190

Summary: Debug REST API tests
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Test SuiteAssignee: Jonathan Druart <jonathan.druart>
Status: In Discussion --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: martin.renvoize, nick, tomascohen
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25504
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 27190: [DO NOT PUSH] example of failure
Bug 27190: Test::Mojo - Always warn the error string on error

Description Jonathan Druart 2020-12-10 15:55:10 UTC
It can be tricky to debug REST API tests. You can get a "received 500 when 200 expected", but you don't have the error.

There is one manual way to do it:

$t->put_ok($url)->status_is(200)->json_is($expected_json)->or( sub { warn $t->tx->res->to_string });

But could we provide a generic way to add a diag in case Test::Mojo fails?
Comment 1 Jonathan Druart 2020-12-10 15:56:50 UTC
Created attachment 114313 [details] [review]
Bug 27190: [DO NOT PUSH] example of failure

Apply patches from 18729 to test this change.
Comment 2 Jonathan Druart 2020-12-10 15:57:16 UTC
Created attachment 114314 [details] [review]
Bug 27190: Test::Mojo - Always warn the error string on error
Comment 3 Jonathan Druart 2020-12-10 15:58:29 UTC
That's pretty ugly, and we will certainly never push it. But at least I will remember next time I need it, hopefully!
Comment 4 Katrin Fischer 2023-07-01 14:44:09 UTC
(In reply to Jonathan Druart from comment #3)
> That's pretty ugly, and we will certainly never push it. But at least I will
> remember next time I need it, hopefully!

Should we close then?
Comment 5 Jonathan Druart 2023-07-04 08:41:34 UTC
(In reply to Katrin Fischer from comment #4)
> (In reply to Jonathan Druart from comment #3)
> > That's pretty ugly, and we will certainly never push it. But at least I will
> > remember next time I need it, hopefully!
> 
> Should we close then?

I don't think so. It's still useful for debugging purpose and we should have something similar in master.