The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

use strict;
use lib qw(t/lib);
my $mech = Test::WWW::Mechanize::Catalyst->new( agent => 'Safari');
my $tid = 1;
ok(
my $api = MyApp->controller('API')->api,
'get api directly from controller'
);
ok(
$mech->request(
POST $api->{url},
Content_Type => 'application/json',
Content => encode_json(
{
action => 'JSON',
method => 'index',
tid => $tid,
data => [],
type => 'rpc',
}
)
),
'get json response'
);
like( $mech->content, qr/{"foo":"bar"}/, 'json works' );
done_testing;