in reply to Testing javascript on Dancer2 psgi sites

You can run any PSGI app together with your WWW::Mechanize::Chrome test script in the same process if you use a webserver like Twiggy. That allows you to conveniently test your Javascript without launching a separate process for your web application.

  • Comment on Re: Testing javascript on Dancer2 psgi sites

Replies are listed 'Best First'.
Re^2: Testing javascript on Dancer2 psgi sites
by nysus (Parson) on Jan 06, 2018 at 16:24 UTC

    How about Starman? I'm already using that.

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

      I don't think my approach would work with Starman, since Starman uses fork, which means you will have more than one process running.

      Having more than one process running means that your test code will run more than once, which is at least not what I want when writing tests.

        You can tellstarman to not fork any children via max_servers=1 IIRC. (Might be 0, unsure. On mobile now...

        The way forward always starts with a minimal test.

        I'm still uncertain as to how I would do this. I tried this:

        my $test = Plack::Test->create($app, server => 'Twiggy', port => 5000);

        But I'm not sure how get WWW::Mechanize::Chome to make requests on the $test object. Can you give me a couple of hints?

        $PM = "Perl Monk's";
        $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest";
        $nysus = $PM . ' ' . $MCF;
        Click here if you love Perl Monks