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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |