Skip to content

Instantly share code, notes, and snippets.

@misterdjules
Created May 26, 2014 01:32
Show Gist options
  • Select an option

  • Save misterdjules/c6aaf12b4d2b06f1e99c to your computer and use it in GitHub Desktop.

Select an option

Save misterdjules/c6aaf12b4d2b06f1e99c to your computer and use it in GitHub Desktop.
casper.test.begin "Login with Sammy.js routing", 4, (test) ->
casper.start someHost
casper.then ->
test.assertExists "form#login-form", "Index page must have a register form."
# This is needed so that your frontend code can do whatever it needs
# to do (like loading models) when initializing your single page app.
# Going to the next step without the initialization completed can make it look
# like issues happen in the next steps for other reasons.
this.wait 1000, ->
casper.log "Waiting for loading..."
casper.then ->
this.fill "form#login-form", { "username": "test", "password": "test" }, false
this.click "form#login-form #btn-login"
# Setting navigationRequested to true is needed to tell casperjs
# that navigation to another location is expected.
this.navigationRequested = true
casper.then ->
casper.log "current URL: #{this.getCurrentUrl()}"
test.assertUrlMatch /#\/user\/loggedin\/route/, "User is redirected to the expected frontend route"
casper.run ->
test.done()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment