Skip to content

Instantly share code, notes, and snippets.

@n1k0
Last active December 13, 2015 23:09
Show Gist options
  • Save n1k0/4989799 to your computer and use it in GitHub Desktop.
Save n1k0/4989799 to your computer and use it in GitHub Desktop.

Notes about your presentation draft

As kindly requested :)

Other than that, great presentation, all the best :)

PS: I slightly rewrote your demo example and added a 1.1-dev version, see below

# to be executed using $ casperjs test test-1.0.coffee --direct --log-level=debug
casper.options.clientScripts = ["includes/underscore-min.js"]
testedName = 'Aurelien'
testedRepetition = 5
casper.start 'http://localhost:9000/', () ->
@test.assertTitle 'The "helloworld" application', 'hello world application expected'
@test.assertTextExists 'Configure', 'you can configure the app'
@fill 'form[action="/hello"]',
name: testedName
repeat: testedRepetition
color: 'red'
, true
casper.then () ->
@test.assertTitle 'Here is the result:', 'result page expected'
casper.then () ->
@test.assertTextExists "Hello #{testedName}!", 'message displayed correctly'
@test.assertUrlMatch /name=Aurelien/, 'search term has been submitted'
@capture 'page.png'
@test.assertEval (times, name) ->
elements = __utils__.findAll 'li'
return false if elements.length is not times
_.every elements, (e) ->
e.textContent is "Hello #{name}!"
, "message displayed more that #{testedRepetition} times"
, [testedRepetition, testedName]
casper.thenClick '.buttons a', () ->
@test.assertTitle 'The "helloworld" application', 'hello world application expected'
casper.back () ->
@test.assertTitle 'Here is the result:', 'result page expected'
casper.run () ->
@test.done 8 #checks that 7 assertions have been executed
@test.renderResults true
# to be executed using $ casperjs test test-1.1-dev.coffee --direct --log-level=debug
casper.options.clientScripts = ["includes/underscore-min.js"]
casper.test.begin "Aurelien's site tests", 8, (test) ->
testedName = 'Aurelien'
testedRepetition = 5
casper.start 'http://localhost:9000/', () ->
test.assertTitle 'The "helloworld" application', 'hello world application expected'
test.assertTextExists 'Configure', 'you can configure the app'
@fill 'form[action="/hello"]',
name: testedName
repeat: testedRepetition
color: 'red'
, true
casper.then () ->
test.assertTitle 'Here is the result:', 'result page expected'
casper.then () ->
test.assertTextExists "Hello #{testedName}!", 'message displayed correctly'
test.assertUrlMatch /name=Aurelien/, 'search term has been submitted'
@capture 'page.png'
test.assertEval (times, name) ->
elements = __utils__.findAll 'li'
return false if elements.length is not times
_.every elements, (e) ->
e.textContent is "Hello #{name}!"
, "message displayed more that #{testedRepetition} times"
, [testedRepetition, testedName]
casper.thenClick '.buttons a', () ->
test.assertTitle 'The "helloworld" application', 'hello world application expected'
casper.back () ->
test.assertTitle 'Here is the result:', 'result page expected'
casper.run () -> test.done()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment