##// END OF EJS Templates
jstest moved to new place, closes #3125
jstest moved to new place, closes #3125

File last commit:

r13257:8b549e77
r13257:8b549e77
Show More
util.js
52 lines | 1.3 KiB | application/javascript | JavascriptLexer
//
// Utility functions for the HTML notebook's CasperJS tests.
//
// Get the URL of a notebook server on which to run tests.
casper.getNotebookServer = function () {
return 'http://127.0.0.1:8888';
};
// Create and open a new notebook.
casper.openNewNotebook = function () {
var baseUrl = this.getNotebookServer();
this.start(baseUrl + '/new');
};
// Shut down the current notebook's kernel.
casper.shutdownCurrentKernel = function () {
this.thenEvaluate(function() {
IPython.notebook.kernel.kill();
});
};
// Delete created notebook.
casper.deleteCurrentNotebook = function () {
this.thenEvaluate(function() {
var nbData = $('body').data();
var url = nbData.baseProjectUrl + 'notebooks/' + nbData.notebookId;
$.ajax(url, {
type: 'DELETE',
});
});
};
// Wrap a notebook test to reduce boilerplate.
casper.notebookTest = function(test) {
this.openNewNotebook();
this.then(test);
this.shutdownCurrentKernel();
this.deleteCurrentNotebook();
// Run the browser automation.
this.run(function() {
this.test.done();
});
};
// Pass `console.log` calls from page JS to casper.
casper.printLog = function () {
this.on('remote.message', function(msg) {
this.echo('Remote message caught: ' + msg);
});
};