Skip to content

Instantly share code, notes, and snippets.

View whharris's full-sized avatar

Wesley Harris whharris

  • x.ai
  • New York City
View GitHub Profile
@whharris
whharris / gist:52c073b36c75945c80a1
Last active January 5, 2016 22:47
Make Assertions on Resource Requests using Casper.js and Phantom.js

Acceptance Testing Data Collection: Asserting On Outbound Resource Requests Using CasperJS and PhantomJS

At Intent Media, we run ad networks, which means that on the data science team, we don't just science data, we also collect it.

One way in which we accomplish this collection is through the use of beacons on our partners' sites. And because we are nearly as excited about software testing as we are about statistical modeling and Hadoop-ing, we also want to do proper acceptance testing of our beacons.

Acceptance testing for us means that we need a way to assert that a browser, upon executing our javascript, will make a request to our beacon url. It turns out that our pal PhantomJS has a handy method for handling this kind of thing, and our favorite PhantomJS wrapper CasperJS emits [an event