Skip to content

Instantly share code, notes, and snippets.

@xcambar
Created March 14, 2013 17:43
Show Gist options
  • Save xcambar/5163456 to your computer and use it in GitHub Desktop.
Save xcambar/5163456 to your computer and use it in GitHub Desktop.
An example for Clouseau
var clouseau = require('clouseau-js');
function alertCheck(page) {
var dfd = this; // `this` is a deferred! \o/
page.onAlert = function (txt) {
if (txt !== 'MY EXPECTED MESSAGE') {
return dfd.reject(new Error("Unexpected message: " + txt));
}
return dfd.resolve(page);
};
};
var check1 = clouseau.addCheckpoint(alertCheck, 10000); // timeout in ms
clouseau.start("http://your.domain.com/end/point")
.then(check1)
.then(function () { console.log('OK'); }, function () { console.log('Fail'); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment