Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Run both zepto and jQuery tests

  • Loading branch information...
commit e792e0e27236f601aa88c7c6cb78e3a383e99b44 1 parent 4a72cfd
@ipmb ipmb authored
Showing with 31 additions and 15 deletions.
  1. +31 −15 phantom-js-loader.js
View
46 phantom-js-loader.js
@@ -2,22 +2,38 @@
var fs = require('fs'),
page = new WebPage(),
file = fs.absolute('test/test.html');
+ testResults = {};
+
page.onConsoleMessage = function(msg) {
- console.log(msg);
- if (/^Tests completed in/.test(msg)) {
- phantom.exit(page.evaluate(function () {
- if (window.QUnit && QUnit.config && QUnit.config.stats) {
- return QUnit.config.stats.bad || 0;
+ console.log(page.lib + ': ' + msg);
+ if (/^Tests completed in/.test(msg)) {
+ testResults[page.lib] = page.evaluate(function () {
+ if (window.QUnit && QUnit.config && QUnit.config.stats) {
+ return QUnit.config.stats.bad || 0;
+ }
+ return 1;
+ });
+ if (Object.keys(testResults).length === 2) {
+ phantom.exit(testResults.jQuery || testResults.zepto);
}
- return 1;
- }));
- }
-};
+ }
+ };
+
+function runTests(filePath, lib) {
+ filePath = 'file://' + filePath + '?lib=' + lib;
+ console.log("Testing " + filePath);
+ page.open( filePath, function (status) {
+ page.lib = lib;
+ if (status !== 'success') {
+ console.log('FAIL to load the address');
+ phantom.exit(1);
+ }
+ });
+}
-page.open('file://' + file, function (status) {
- if (status !== 'success') {
- console.log('FAIL to load the address');
- phantom.exit(1);
- }
-});
+runTests(file, 'jQuery');
+// quick and dirty: wait 1 second, then test with zepto
+setTimeout(function () {
+ runTests(file, 'zepto');
+}, 1000);
Please sign in to comment.
Something went wrong with that request. Please try again.