The docs weren't really useful - too brief and vague. As I understood from the docs, We just need to to run casperjs command on the the directory of tests and ensure each test ends with Tester.done()
. Here are my two tests,
//test1.js
var casper = require('casper').create();
var urlPrefix = "http://localhost/NavHawk2/";
casper.start(urlPrefix , function() {
this.test.assertSelectorHasText('title', 'Login', 'Title Ok! Login Page Expected');
this.test.assertExists('form[action$="/login"]', 'Login Form is found');
this.fill('form[action$="/login"]', {
.....
}, true);
});
casper.run(function() {
this.test.done(2);
});
//test2.js
var blinkingCircleImg = "7.gif"
casper.on('page.error', function(){
console.log("SOme Javascript error persists!");
});
casper.then(function(){
this.test.assertSelectorHasText('title', 'Map', 'Login Ok! Map Page Expected');
this.test.assertExists('img[src$="' + blinkingCircleImg + '"]', 'Blinking Circle being shown!');
this.test.assetNotVisible('#sidebar_content_geofences', 'Geofencing sidebar not being shown!');
});
casper.run(function() {
this.test.renderResults(true);
this.test.done(3);
});
The thing is that test2.js
file is never run. Maybe I am wrong somewhere.
Several things here:
casperjs test
subcommandcasperjs test
subcommandThere's a useful gist which demonstrates how the command may/should be used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With