Commit 69464641 69464641f1e76f5ebd3440584c5e2f7e0a2b8f54 by Nicolas Perriault

added hint printing when a possible `casperjs` command call is detected

1 parent d9b240c8
......@@ -15,6 +15,7 @@ XXXX-XX-XX, v1.0.0
- merged PR [#319](https://github.com/n1k0/casperjs/pull/319), fixed [#209](https://github.com/n1k0/casperjs/issues/209) - test duration has been added to XUnit XML result file.
- `Casper.userAgent()` does not require the instance to be started anymore
- dubious tests now have dedicated color & styling
- added hint printing when a possible `casperjs` command call is detected
2012-12-14, v1.0.0-RC6
----------------------
......
......@@ -164,10 +164,21 @@ function patchRequire(require, requireDirs) {
function bootstrap(global) {
"use strict";
var phantomArgs = require('system').args;
/**
* Hooks in default phantomjs error handler to print a hint when a possible
* casperjs command misuse is detected.
*
*/
phantom.onError = function onPhantomError(msg, trace) {
phantom.defaultErrorHandler.apply(phantom, arguments);
if (msg.indexOf("ReferenceError: Can't find variable: casper") === 0) {
console.error('Hint: you may want to use the `casperjs test` command.');
}
};
/**
* Loads and initialize the CasperJS environment.
*/
phantom.loadCasper = function loadCasper() {
......