Skip to content

Instantly share code, notes, and snippets.

@martintrojer
Created September 15, 2015 18:02
Show Gist options
  • Save martintrojer/9a8e78126063705fabdb to your computer and use it in GitHub Desktop.
Save martintrojer/9a8e78126063705fabdb to your computer and use it in GitHub Desktop.
(function() {
var Ap = Array.prototype;
var slice = Ap.slice;
var Fp = Function.prototype;
if (!Fp.bind) {
// PhantomJS doesn't support Function.prototype.bind natively, so
// polyfill it whenever this module is required.
Fp.bind = function(context) {
var func = this;
var args = slice.call(arguments, 1);
function bound() {
var invokedAsConstructor = func.prototype && (this instanceof func);
return func.apply(
// Ignore the context parameter when invoking the bound function
// as a constructor. Note that this includes not only constructor
// invocations using the new keyword but also calls to base class
// constructors such as BaseClass.call(this, ...) or super(...).
!invokedAsConstructor && context || this,
args.concat(slice.call(arguments))
);
}
// The bound function must share the .prototype of the unbound
// function so that any object created by one constructor will count
// as an instance of both constructors.
bound.prototype = func.prototype;
return bound;
};
}
})();
<html>
<body>
<script> var apiUrl="http://api:8030"; </script>
<script> var sseUrl="http://see:8050"; </script>
<script src="phantomjs-shims.js" type="text/javascript"></script>
<script src="../target/site_tests.js" type="text/javascript"></script>
</body>
</html>
/*global phantom,setTimeout,require,last_test_run_successful */
var system = require('system');
var page = require('webpage').create();
var url = system.args[1];
page.onConsoleMessage = function (message) {
console.log(message);
};
function exit(code) {
setTimeout(function(){ phantom.exit(code); }, 0);
phantom.onError = function(){};
}
console.log("Loading URL: " + url);
page.open(url, function (status) {
if (status != "success") {
console.log('Failed to open ' + url);
phantom.exit(1);
}
var result = page.evaluate(function() {
return azondi.site.core_test.run_all_phantom();
});
var last_test_run_successful = page.evaluate(function () {
return last_test_run_successful;
});
if (last_test_run_successful) {
console.log("Tests succeeded.");
phantom.exit(0);
} else {
console.log("*** Tests failed! ***");
phantom.exit(1);
}
});
@martintrojer
Copy link
Author

Thanks! This solved it for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment