piskel/test/casperjs/DrawingTest.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

2014-08-22 02:37:35 +04:00
(function () {
2016-08-31 15:11:29 +03:00
var tests = require('../drawing/DrawingTests.casper.js').tests;
// Polyfill for Object.assign (missing in PhantomJS)
casper.options.clientScripts.push('./node_modules/phantomjs-polyfill-object-assign/object-assign-polyfill.js');
2014-08-22 02:37:35 +04:00
var baseUrl = casper.cli.get('baseUrl')+"?debug";
var resultSelector = '#drawing-test-result';
2016-08-31 15:11:29 +03:00
casper.test.begin('Drawing Tests', tests.length, function(test) {
casper.start();
var runTest = function (index) {
var currentTest = 'drawing/tests/' + tests[index];
casper.open(baseUrl + "&test-run=" + currentTest);
casper.then(function () {
this.echo('Running test : ' + currentTest);
this.echo('... Waiting for test result : ' + resultSelector);
this.waitForSelector(resultSelector, function () {
// then
var result = this.getHTML(resultSelector);
this.echo('... Test finished : ' + result);
test.assertEquals(result, 'OK');
}, function () {
// onTimeout
test.fail('Test timed out');
}, 30 * 1000);
2016-08-31 15:11:29 +03:00
})
.run(function () {
if (tests[index+1]) {
runTest(index+1);
} else {
test.done();
}
});
};
runTest(0);
});
2017-01-08 22:43:15 +03:00
})();