mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Merge pull request #536 from david-szabo97/update_phantomjs_casperjs
Update PhantomJS and CasperJS
This commit is contained in:
commit
4d12908363
@ -6,7 +6,7 @@ before_install:
|
|||||||
- npm install -g grunt-cli
|
- npm install -g grunt-cli
|
||||||
- git clone git://github.com/n1k0/casperjs.git ~/casperjs
|
- git clone git://github.com/n1k0/casperjs.git ~/casperjs
|
||||||
- cd ~/casperjs
|
- cd ~/casperjs
|
||||||
- git checkout tags/1.0.2
|
- git checkout tags/1.1.3
|
||||||
- export PATH=$PATH:`pwd`/bin
|
- export PATH=$PATH:`pwd`/bin
|
||||||
- cd -
|
- cd -
|
||||||
before_script:
|
before_script:
|
||||||
|
31
Gruntfile.js
31
Gruntfile.js
@ -39,19 +39,18 @@ module.exports = function(grunt) {
|
|||||||
var tests = prefixPaths(testPaths, "test/casperjs/");
|
var tests = prefixPaths(testPaths, "test/casperjs/");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
filesSrc : tests,
|
files : {src: tests},
|
||||||
options : {
|
options : {
|
||||||
args : {
|
casperjsOptions: [
|
||||||
baseUrl : 'http://' + host + ':' + PORT.TEST,
|
'--baseUrl=http://' + host + ':' + PORT.TEST,
|
||||||
mode : DEV_MODE,
|
'--mode=' + DEV_MODE,
|
||||||
delay : delay
|
'--delay=' + delay,
|
||||||
},
|
'--verbose=false',
|
||||||
async : false,
|
'--log-level=info',
|
||||||
direct : false,
|
'--print-command=false',
|
||||||
logLevel : 'info',
|
'--print-file-paths=true',
|
||||||
printCommand : false,
|
]
|
||||||
printFilePaths : true
|
},
|
||||||
}
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -282,7 +281,7 @@ module.exports = function(grunt) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
ghost : {
|
casperjs : {
|
||||||
'travis' : getCasperConfig('TravisTestSuite.js', 10000, hostname),
|
'travis' : getCasperConfig('TravisTestSuite.js', 10000, hostname),
|
||||||
'local' : getCasperConfig('LocalTestSuite.js', 50, hostname)
|
'local' : getCasperConfig('LocalTestSuite.js', 50, hostname)
|
||||||
},
|
},
|
||||||
@ -320,10 +319,10 @@ module.exports = function(grunt) {
|
|||||||
grunt.registerTask('unit-test', ['karma']);
|
grunt.registerTask('unit-test', ['karma']);
|
||||||
|
|
||||||
// Validate & Test
|
// Validate & Test
|
||||||
grunt.registerTask('test-travis', ['lint', 'unit-test', 'build-dev', 'connect:test', 'ghost:travis']);
|
grunt.registerTask('test-travis', ['lint', 'unit-test', 'build-dev', 'connect:test', 'casperjs:travis']);
|
||||||
// Validate & Test (faster version) will NOT work on travis !!
|
// Validate & Test (faster version) will NOT work on travis !!
|
||||||
grunt.registerTask('test-local', ['lint', 'unit-test', 'build-dev', 'connect:test', 'ghost:local']);
|
grunt.registerTask('test-local', ['lint', 'unit-test', 'build-dev', 'connect:test', 'casperjs:local']);
|
||||||
grunt.registerTask('test-local-nolint', ['unit-test', 'build-dev', 'connect:test', 'ghost:local']);
|
grunt.registerTask('test-local-nolint', ['unit-test', 'build-dev', 'connect:test', 'casperjs:local']);
|
||||||
|
|
||||||
grunt.registerTask('test', ['test-travis']);
|
grunt.registerTask('test', ['test-travis']);
|
||||||
grunt.registerTask('precommit', ['test-local']);
|
grunt.registerTask('precommit', ['test-local']);
|
||||||
|
@ -8,6 +8,9 @@ module.exports = function(config) {
|
|||||||
var piskelScripts = require('./src/piskel-script-list.js').scripts.map(mapToSrcFolder);
|
var piskelScripts = require('./src/piskel-script-list.js').scripts.map(mapToSrcFolder);
|
||||||
piskelScripts.push('test/js/testutils/**/*.js');
|
piskelScripts.push('test/js/testutils/**/*.js');
|
||||||
piskelScripts.push('test/js/**/*.js');
|
piskelScripts.push('test/js/**/*.js');
|
||||||
|
|
||||||
|
// Polyfill for Object.assign (missing in PhantomJS)
|
||||||
|
piskelScripts.push('./node_modules/phantomjs-polyfill-object-assign/object-assign-polyfill.js');
|
||||||
|
|
||||||
config.set({
|
config.set({
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"dateformat": "1.0.11",
|
"dateformat": "1.0.11",
|
||||||
"grunt": "^0.4.5",
|
"grunt": "^0.4.5",
|
||||||
|
"grunt-casperjs": "^2.2.1",
|
||||||
"grunt-contrib-clean": "1.0.0",
|
"grunt-contrib-clean": "1.0.0",
|
||||||
"grunt-contrib-concat": "1.0.1",
|
"grunt-contrib-concat": "1.0.1",
|
||||||
"grunt-contrib-connect": "1.0.2",
|
"grunt-contrib-connect": "1.0.2",
|
||||||
@ -36,7 +37,6 @@
|
|||||||
"grunt-contrib-jshint": "1.0.0",
|
"grunt-contrib-jshint": "1.0.0",
|
||||||
"grunt-contrib-uglify": "1.0.1",
|
"grunt-contrib-uglify": "1.0.1",
|
||||||
"grunt-contrib-watch": "1.0.0",
|
"grunt-contrib-watch": "1.0.0",
|
||||||
"grunt-ghost": "1.1.0",
|
|
||||||
"grunt-include-replace": "4.0.1",
|
"grunt-include-replace": "4.0.1",
|
||||||
"grunt-jscs": "2.8.0",
|
"grunt-jscs": "2.8.0",
|
||||||
"grunt-karma": "1.0.0",
|
"grunt-karma": "1.0.0",
|
||||||
@ -51,7 +51,8 @@
|
|||||||
"karma-jasmine": "1.0.2",
|
"karma-jasmine": "1.0.2",
|
||||||
"karma-phantomjs-launcher": "0.2.3",
|
"karma-phantomjs-launcher": "0.2.3",
|
||||||
"load-grunt-tasks": "3.5.0",
|
"load-grunt-tasks": "3.5.0",
|
||||||
"phantomjs": "1.9.19"
|
"phantomjs": "2.1.7",
|
||||||
|
"phantomjs-polyfill-object-assign": "0.0.2"
|
||||||
},
|
},
|
||||||
"window": {
|
"window": {
|
||||||
"title": "Piskel",
|
"title": "Piskel",
|
||||||
|
@ -1,42 +1,48 @@
|
|||||||
(function () {
|
(function () {
|
||||||
var tests = require('./test/drawing/DrawingTests.casper.js').tests;
|
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');
|
||||||
|
|
||||||
var baseUrl = casper.cli.get('baseUrl')+"?debug";
|
var baseUrl = casper.cli.get('baseUrl')+"?debug";
|
||||||
var resultSelector = '#drawing-test-result';
|
var resultSelector = '#drawing-test-result';
|
||||||
|
|
||||||
casper.start();
|
|
||||||
|
|
||||||
var runTest = function (index) {
|
casper.test.begin('Drawing Tests', tests.length, function(test) {
|
||||||
var test = 'drawing/tests/' + tests[index];
|
casper.start();
|
||||||
|
|
||||||
casper.open(baseUrl + "&test-run=" + test);
|
var runTest = function (index) {
|
||||||
|
var currentTest = 'drawing/tests/' + tests[index];
|
||||||
|
|
||||||
casper.then(function () {
|
casper.open(baseUrl + "&test-run=" + currentTest);
|
||||||
this.echo('Running test : ' + test);
|
|
||||||
this.wait(casper.cli.get('delay'));
|
|
||||||
});
|
|
||||||
|
|
||||||
casper.then(function () {
|
casper.then(function () {
|
||||||
this.echo('... Waiting for test result : ' + resultSelector);
|
this.echo('Running test : ' + currentTest);
|
||||||
this.waitForSelector(resultSelector, function () {
|
this.wait(casper.cli.get('delay'));
|
||||||
// then
|
});
|
||||||
var result = this.getHTML(resultSelector);
|
|
||||||
this.echo('... Test finished : ' + result);
|
|
||||||
this.test.assertEquals(result, 'OK');
|
|
||||||
}, function () {
|
|
||||||
// onTimeout
|
|
||||||
this.test.fail('Test timed out');
|
|
||||||
}, 60*1000);
|
|
||||||
})
|
|
||||||
.run(function () {
|
|
||||||
if (tests[index+1]) {
|
|
||||||
runTest(index+1);
|
|
||||||
} else {
|
|
||||||
this.test.done();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
runTest(0);
|
casper.then(function () {
|
||||||
|
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');
|
||||||
|
}, 15*1000);
|
||||||
|
})
|
||||||
|
.run(function () {
|
||||||
|
if (tests[index+1]) {
|
||||||
|
runTest(index+1);
|
||||||
|
} else {
|
||||||
|
test.done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
runTest(0);
|
||||||
|
});
|
||||||
|
|
||||||
})();
|
})();
|
@ -1,15 +1,19 @@
|
|||||||
casper
|
casper.test.begin('Smoke Test', 2, function(test) {
|
||||||
.start(casper.cli.get('baseUrl')+"?debug")
|
casper
|
||||||
.then(function () {
|
.start(casper.cli.get('baseUrl')+"/?debug")
|
||||||
this.wait(casper.cli.get('delay'));
|
.then(function () {
|
||||||
})
|
this.wait(casper.cli.get('delay'));
|
||||||
.then(function () {
|
})
|
||||||
this.echo(casper.cli.get('baseUrl')+"?debug");
|
.then(function () {
|
||||||
// If there was a JS error after the page load, casper won't perform asserts
|
this.echo(casper.cli.get('baseUrl')+"/?debug");
|
||||||
this.test.assertExists('html', 'Casper JS cannot assert DOM elements. A JS error has probably occured.');
|
// If there was a JS error after the page load, casper won't perform asserts
|
||||||
|
test.assertExists('html', 'Casper JS cannot assert DOM elements. A JS error has probably occured.');
|
||||||
|
|
||||||
this.test.assertExists('#drawing-canvas-container canvas', 'Check if drawing canvas element is created');
|
this.waitForSelector('#drawing-canvas-container canvas', function() {
|
||||||
})
|
test.assertExists('#drawing-canvas-container canvas', 'Check if drawing canvas element is created');
|
||||||
.run(function () {
|
});
|
||||||
this.test.done();
|
})
|
||||||
});
|
.run(function () {
|
||||||
|
test.done();
|
||||||
|
});
|
||||||
|
});
|
@ -1,4 +1,4 @@
|
|||||||
(typeof exports != "undefined" ? exports : pskl_exports).tests = [
|
(typeof exports != "undefined" ? exports : pskl_exports).tests = [
|
||||||
// did not manage to successfully run drawing tests on travis yet ...
|
'SmokeTest.js',
|
||||||
'SmokeTest.js'
|
'DrawingTest.js'
|
||||||
];
|
];
|
Loading…
Reference in New Issue
Block a user