diff --git a/src/raven.js b/src/raven.js index b1ad67a4e457..e5f8780c3a4e 100644 --- a/src/raven.js +++ b/src/raven.js @@ -31,6 +31,8 @@ var _Raven = window.Raven, var Raven = { VERSION: '<%= pkg.version %>', + debug: true, + /* * Allow multiple versions of Raven to be installed. * Strip Raven from the global context and returns the instance. @@ -679,7 +681,7 @@ function makeRequest(data) { function isSetup() { if (!hasJSON) return false; // needs JSON support if (!globalServer) { - if (window.console && console.error) { + if (window.console && console.error && Raven.debug) { console.error("Error: Raven has not been configured."); } return false; diff --git a/test/raven.test.js b/test/raven.test.js index f65fb38bb264..b5c42496a15e 100644 --- a/test/raven.test.js +++ b/test/raven.test.js @@ -215,11 +215,27 @@ describe('globals', function() { assert.isFalse(isSetup()); }); - it('should return false when Raven is not configured and write to console.error', function() { + it('should return false when Raven is not configured', function() { hasJSON = true; // be explicit globalServer = undefined; this.sinon.stub(console, 'error'); assert.isFalse(isSetup()); + }); + + it('should not write to console.error when Raven is not configured and Raven.debug is false', function() { + hasJSON = true; // be explicit + globalServer = undefined; + Raven.debug = false; + this.sinon.stub(console, 'error'); + isSetup(); + assert.isFalse(console.error.calledOnce); + }); + + it('should write to console.error when Raven is not configured and Raven.debug is true', function() { + hasJSON = true; // be explicit + globalServer = undefined; + this.sinon.stub(console, 'error'); + isSetup(); assert.isTrue(console.error.calledOnce); });