Skip to content

Instantly share code, notes, and snippets.

@todoubled
Created December 17, 2012 02:27
Show Gist options
  • Save todoubled/4315415 to your computer and use it in GitHub Desktop.
Save todoubled/4315415 to your computer and use it in GitHub Desktop.
Example casper.js test
query = 'portland'
types = 'foo,bar,baz'
params = /// chicago/all/#{types} ///
casper.start 'http://localhost:8081', ->
@setupCookie 'chicago'
@reload()
.then ->
@test.comment 'Select location'
@click '#location-trigger'
.waitForText 'Enter an address, city or zip code.', ->
@test.assertExists 'input#geocode', 'The geocode input is rendered'
@fill 'form#set-location', 'geocode': query
@click '.location-bar button'
.then ->
@assertCookie query
.waitForText 'Results:', ->
@test.assertUrlMatch params, "The search is saved at #finder#{params}."
.then ->
@test.assertTextExists 'Search results below', 'Search results are shown.'
.waitForSelector '#results', ->
@assertApiCall query, types
.run ->
@test.done()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment