Commit 7d0b40a5 7d0b40a5fb2ee2ed2ae0ec6c6d1680e57c012070 by Nicolas Perriault

fixes #260 - Don't display test error messages when not testing

1 parent c55dc1bc
...@@ -269,6 +269,7 @@ function bootstrap(global) { ...@@ -269,6 +269,7 @@ function bootstrap(global) {
269 phantom.exit(0); 269 phantom.exit(0);
270 } else if (phantom.casperArgs.get(0) === "test") { 270 } else if (phantom.casperArgs.get(0) === "test") {
271 phantom.casperScript = fs.absolute(fs.pathJoin(phantom.casperPath, 'tests', 'run.js')); 271 phantom.casperScript = fs.absolute(fs.pathJoin(phantom.casperPath, 'tests', 'run.js'));
272 phantom.casperTest = true;
272 phantom.casperArgs.drop("test"); 273 phantom.casperArgs.drop("test");
273 } else if (phantom.casperArgs.get(0) === "selftest") { 274 } else if (phantom.casperArgs.get(0) === "selftest") {
274 phantom.casperScript = fs.absolute(fs.pathJoin(phantom.casperPath, 'tests', 'run.js')); 275 phantom.casperScript = fs.absolute(fs.pathJoin(phantom.casperPath, 'tests', 'run.js'));
......
...@@ -610,9 +610,19 @@ Tester.prototype.comment = function comment(message) { ...@@ -610,9 +610,19 @@ Tester.prototype.comment = function comment(message) {
610 this.casper.echo('# ' + message, 'COMMENT'); 610 this.casper.echo('# ' + message, 'COMMENT');
611 }; 611 };
612 612
613 /**
614 * Configure casper callbacks for testing purpose.
615 *
616 */
613 Tester.prototype.configure = function configure() { 617 Tester.prototype.configure = function configure() {
614 "use strict"; 618 "use strict";
615 var tester = this; 619 var tester = this;
620
621 // Do not hook casper if we're not testing
622 if (!phantom.casperTest) {
623 return;
624 }
625
616 // specific timeout callbacks 626 // specific timeout callbacks
617 this.casper.options.onStepTimeout = function test_onStepTimeout(timeout, step) { 627 this.casper.options.onStepTimeout = function test_onStepTimeout(timeout, step) {
618 tester.fail(f("Step timeout occured at step %d (%dms)", step, timeout)); 628 tester.fail(f("Step timeout occured at step %d (%dms)", step, timeout));
......