use Mojo::Base -strict; use Test::Mojo; use Test::More; use Mojolicious::Lite; app->defaults( handler => 'my_handler' ); get '/example' => sub{ die }; hook before_render => sub { my( $c, $a ) = @_; my $s = $c->stash; # Because { handler } is changed between probes while `_fallbacks` # we can not get original value for { handler } # TODO: Keep the stash in same state when exception occur for each render_maybe $s->{ result } .= $a->{ template } .': ah:'.$a->{ handler } .' af:' .$a->{ format } .': sh:'.$s->{ handler } .' sf:' .$s->{ format } ."\n"; }; my $t = Test::Mojo->new; $t->get_ok( '/example.json' )->content_is( <{ result } __END__ ok 1 - GET /example.json not ok 2 - exact match for content # Failed test 'exact match for content' # at t/format.t line 21. # got: 'exception.development: ah: af:json: sh:my_handler sf:json # exception: ah: af:json: sh: sf:json # exception.development: ah: af:html: sh: sf:json # exception: ah: af:html: sh: sf:html # # ' # expected: 'exception.development: ah: af:json sh:my_handler sf:json # exception: ah: af:json sh:my_handler sf:json # exception.development: ah: af:html sh:my_handler sf:json # exception: ah: af:html sh:my_handler sf:json # # ' # Tests were run but no plan was declared and done_testing() was not seen.