mardi 30 décembre 2014

casperjs test written in coffeescript hangs

recently I tried to use CoffeeScript for CasperJS tests. So this code below doesn't throw any error, and seems to hang every time I fire it up in CLI.



casper = require("casper")
.create
verbose: true,
logLevel: "debug"

casper_utils = require("utils")
colorizer = require("colorizer").create 'Colorizer'

common_link = "http://0.0.0.0:6543/"

landing_pages = ['g',
'em',
'm1',
'm4',
'mv4',
'mv5',
'mp',
'm2',
'm3',
'rp',
'rc']

reg_hash = '#reg'
reg_modal = '.registration'

pay_hash = '#pay'
pay_modal = '.payment'

checkRegVisibility = ->
@test.assertExists reg_modal
@test.assertVisible reg_modal
@test.assertNotVisible pay_modal

checkPayVisibility = ->
@test.assertExists pay_modal
@test.assertVisible pay_modal
@test.assertNotVisible reg_modal

casper.on 'run.start', ->
@.log 'Casper started'

casper.on 'error', ->
@.log 'error'

casper.on 'http.status.404', ->
@.log '404'

casper.test.begin = ('Initial test', landing_pages.length * 3, suite(test)) ->
landing_pages.forEach (lp, index) ->
casper.start common_link+"?lp="+lp, ->
casper.echo lp
checkRegVisibility()
casper.then common_link+"?lp="+lp+reg_hash, ->
casper.echo lp
checkRegVisibility()
casper.run, ->
test.done()

casper.exit()


Also, is that possible to use JS2Coffee with casperjs tests


Aucun commentaire:

Enregistrer un commentaire