ait has asked for the wisdom of the Perl Monks concerning the following question:

Greetings ye monks!

Is there a way to leverage existing Test::Mojo tests on an already running Mojo app on a remote server ??
I don't see that new() could support a remote server, so is there any trick to do this?
Many TIA!
-- Alex

Replies are listed 'Best First'.
Re: Mojolicious Test::Mojo remote app
by davido (Cardinal) on Feb 16, 2022 at 22:25 UTC

    See Mojolicious Guides Testing: The Test::Mojo-object.

    In short, yes, you can specify the entire URL to issue requests against, allowing you to test remote web applications. This works because Test::Mojo contains a Mojo::UserAgent object.

    As an example:

    #!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Mojo; my $t = Test::Mojo->new; $t->get_ok('https://www.perlmonks.org') ->status_is(200); done_testing();

    If you run that you should see:

    ok 1 - GET https://www.perlmonks.org ok 2 - 200 OK 1..2

    Dave

      That's awesome !
      Thank you !!