Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated ignore errors #224

Merged
merged 2 commits into from
Jul 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ var Raven = {
globalOptions.ignoreErrors.push('Script error.');
globalOptions.ignoreErrors.push('Script error');

// Other variants of external script errors:
globalOptions.ignoreErrors.push('Javascript error: Script error on line 0');
globalOptions.ignoreErrors.push('Javascript error: Script error. on line 0');

// join regexp rules into one big rule
globalOptions.ignoreErrors = joinRegExp(globalOptions.ignoreErrors);
globalOptions.ignoreUrls = globalOptions.ignoreUrls.length ? joinRegExp(globalOptions.ignoreUrls) : false;
Expand Down
22 changes: 14 additions & 8 deletions test/raven.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('TraceKit', function(){
if (numDone == numReports) {
done();
}
}
};
TraceKit.report.subscribe(subscriptionHandler);

// TraceKit.report always throws an exception in order to trigger
Expand Down Expand Up @@ -181,7 +181,7 @@ describe('globals', function() {
assert.isTrue(isString(''));
assert.isFalse(isString({}));
assert.isFalse(isString(undefined));
assert.isFalse(isString(function(){}))
assert.isFalse(isString(function(){}));
});
});

Expand Down Expand Up @@ -1080,6 +1080,17 @@ describe('Raven (public API)', function() {
});
});

describe('ignore errors', function() {
it('should install default ignore errors', function() {
Raven.config('//abc@example.com/2');

assert.isTrue(globalOptions.ignoreErrors.test('Script error'), 'it should install "Script error" by default');
assert.isTrue(globalOptions.ignoreErrors.test('Script error.'), 'it should install "Script error." by default');
assert.isTrue(globalOptions.ignoreErrors.test('Javascript error: Script error on line 0'), 'it should install "Javascript error: Script error on line 0" by default');
assert.isTrue(globalOptions.ignoreErrors.test('Javascript error: Script error. on line 0'), 'it should install "Javascript error: Script error. on line 0" by default');
});
});

describe('callback function', function() {
it('should callback a function if it is global', function() {
window.RavenConfig = {
Expand All @@ -1094,8 +1105,7 @@ describe('Raven (public API)', function() {

assert.equal(globalKey, 'random');
assert.equal(globalServer, 'http://some.other.server:80/api/2/store/');
assert.isTrue(globalOptions.ignoreErrors.test('Script error'), 'it should install "Script error" by default');
assert.isTrue(globalOptions.ignoreErrors.test('Script error.'), 'it should install "Script error." by default');

assert.equal(globalOptions.some, 'config');
assert.equal(globalProject, '2');

Expand All @@ -1111,8 +1121,6 @@ describe('Raven (public API)', function() {
assert.equal(Raven, Raven.config(SENTRY_DSN, {foo: 'bar'}), 'it should return Raven');
assert.equal(globalKey, 'abc');
assert.equal(globalServer, 'http://example.com:80/api/2/store/');
assert.isTrue(globalOptions.ignoreErrors.test('Script error'), 'it should install "Script error" by default');
assert.isTrue(globalOptions.ignoreErrors.test('Script error.'), 'it should install "Script error." by default');
assert.equal(globalOptions.foo, 'bar');
assert.equal(globalProject, '2');
assert.isTrue(isSetup());
Expand All @@ -1122,8 +1130,6 @@ describe('Raven (public API)', function() {
Raven.config('//abc@example.com/2');
assert.equal(globalKey, 'abc');
assert.equal(globalServer, '//example.com/api/2/store/');
assert.isTrue(globalOptions.ignoreErrors.test('Script error'), 'it should install "Script error" by default');
assert.isTrue(globalOptions.ignoreErrors.test('Script error.'), 'it should install "Script error." by default');
assert.equal(globalProject, '2');
assert.isTrue(isSetup());
});
Expand Down