I did a little more research on Plack::Test. So it turns out you can use it to start up a server with $Plack::Test::Impl like so:

use lib 'lib'; BEGIN { $ENV{'DANCER_ENVIRONMENT'} = 'testing' } use Log::Log4perl qw(:easy); use VoteTracker; use Test::More; use Test::HTML::Content; use Plack::Test; use WWW::Mechanize::Chrome; $Plack::Test::Impl = "Server"; Log::Log4perl->easy_init($ERROR); my $app = VoteTracker->to_app; my $test = Plack::Test->create($app); my $port = $test->port; my $mech = WWW::Mechanize::Chrome->new( headless => 1, report_js_error +s => 1, ); $mech->allow( javascript => 1 ); $mech->get("http://localhost:$port/path/to/page"); xpath_ok($mech->content, '//h1[text()="Hello"]', 'Has proper title'); done_testing;

So this is great. One thing I noticed, however, is that WWW::Mechanize::Chrome is really slow to load. If each test script fires up Chrome, it will take an exceedingly long time to run the tests. Is there a way I can share the Chrome instance across each test?

Update:I've never used it before but I'm thinking Test::Class might be what the doctor ordered to pull this off, right?

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


In reply to Re^8: Testing javascript on Dancer2 psgi sites by nysus
in thread Testing javascript on Dancer2 psgi sites by nysus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.