Test::Mojo::Role::Debug::JSON - a JSON extension to Test::Mojo::Role::Debug
version 0.002
When you chain up a bunch of tests and they fail, you really want an easy way to dump up your markup at a specific point in that chain and see what's what. This module comes to the rescue.
Test::Mojo::Role::Debug::JSON - Test::Mojo role to make debugging test failures easier
This is an extension of Test::Mojo::Role::Debug. Its usage and syntax are very similar. Test::Mojo::Role::Debug provides the subs 'd' and 'da', whereas Test::Mojo::Role::Debug::JSON provides the additional 'djson' and 'djsona'
use Test::More; use Test::Mojo::WithRoles 'Debug::JSON'; my $t = Test::Mojo::WithRoles->new('MyApp'); $t->get_ok('/')->status_is(200) ->d # Does nothing, since test succeeded - on failure dump content ->djson # Does nothing, since test succeeded - on failure dump content as json ->json_like( { status => 'ok' } ) ->da # Always dump reply content ->djsona # Always dump the reply content as json ; done_testing;
You have all the methods provided by Test::Mojo, Test::Mojo::Role::Debug, plus these:
djson
$t->djson; # print the answer as json
Returns its invocant. On failure of previous tests (see "success" in Mojo::DOM), dumps the content output as json.
djsona
$t->djsona;
Same as "djson", except it always dumps, regardless of whether the previous test failed or not.
Test::Mojo::Role::Debug::JSON, Test::Mojo ("or" in Test::Mojo in particular), Mojo::DOM
Fork this module on GitHub: https://github.com/atoomic/Test-Mojo-Role-Debug-JSON
To report bugs or request features, please use https://github.com/atoomic/Test-Mojo-Role-Debug-JSON/issues
Contrinuous integration coverage https://travis-ci.org/atoomic/Test-Mojo-Role-Debug-JSON
You can use and distribute this module under the same terms as Perl itself. See the LICENSE file included in this distribution for complete details.
LICENSE
Nicolas R <atoomic@cpan.org>
This software is copyright (c) 2018 by Nicolas R.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Test::Mojo::Role::Debug::JSON, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Mojo::Role::Debug::JSON
CPAN shell
perl -MCPAN -e shell install Test::Mojo::Role::Debug::JSON
For more information on module installation, please visit the detailed CPAN module installation guide.