Test::Mojo::Role::Debug - Test::Mojo role to make debugging test failures easier
use Test::More; use Test::Mojo::WithRoles 'Debug'; my $t = Test::Mojo::WithRoles->new('MyApp'); $t->get_ok('/')->status_is(200) ->element_exists('existant') ->d # Does nothing, since test succeeded ->element_exists('non_existant') ->d # Dump entire DOM on fail ->d('#foo') # Dump a specific element on fail ->da # Always dump ; done_testing;
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.
You have all the methods provided by Test::Mojo, plus these:
$t->d; # print entire DOM on failure $t->d('#foo'); # print a specific element on failure
Returns its invocant. On failure of previous tests (see "success" in Mojo::DOM), dumps the DOM of the current page to the screen. Takes an optional selector to be passed to "at" in Mojo::DOM, in which case, only the markup of that element will be dumped.
Same as "d", except it always dumps, regardless of whether the previous test failed or not.
Fork this module on GitHub: https://github.com/zoffixznet/Test-Mojo-Role-Debug
To report bugs or request features, please use https://github.com/zoffixznet/Test-Mojo-Role-Debug/issues
If you can't access GitHub, you can email your request to
bug-test-mojo-role-debug at rt.cpan.org
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.