Skip to content

Commit e8417e4

Browse files
committed
test: Add integration test for blacklistUrls config
1 parent 7bccd8f commit e8417e4

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

packages/browser/test/integration/init.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Sentry.init({
3737
attachStacktrace: true,
3838
transport: DummyTransport,
3939
ignoreErrors: ['ignoreErrorTest'],
40+
blacklistUrls: ['foo.js'],
4041
// integrations: function(old) {
4142
// return [new Sentry.Integrations.Debug({ stringify: true })].concat(old);
4243
// },

packages/browser/test/integration/test.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,56 @@ for (var idx in frames) {
101101
}
102102
);
103103
});
104+
105+
it('should allow to ignore specific urls', function(done) {
106+
var iframe = this.iframe;
107+
108+
iframeExecute(
109+
iframe,
110+
done,
111+
function() {
112+
/**
113+
* We always filter on the caller, not the cause of the error
114+
*
115+
* > foo.js file called a function in bar.js
116+
* > bar.js file called a function in baz.js
117+
* > baz.js threw an error
118+
*
119+
* foo.js is blacklisted in the `init` call (init.js), thus we filter it
120+
* */
121+
var urlWithBlacklistedUrl = new Error('filter');
122+
urlWithBlacklistedUrl.stack =
123+
'Error: bar\n' +
124+
' at baz(http://localhost:5000/baz.js:2:9)\n' +
125+
' at bar(http://localhost:5000/bar.js:2:3)\n' +
126+
' at http://localhost:5000/foo.js:7:19';
127+
128+
/**
129+
* > foo-pass.js file called a function in bar-pass.js
130+
* > bar-pass.js file called a function in baz-pass.js
131+
* > baz-pass.js threw an error
132+
*
133+
* foo-pass.js is *not* blacklisted in the `init` call (init.js), thus we don't filter it
134+
* */
135+
var urlWithoutBlacklistedUrl = new Error('pass');
136+
urlWithoutBlacklistedUrl.stack =
137+
'Error: bar\n' +
138+
' at baz(http://localhost:5000/baz-pass.js:2:9)\n' +
139+
' at bar(http://localhost:5000/bar-pass.js:2:3)\n' +
140+
' at http://localhost:5000/foo-pass.js:7:19';
141+
142+
Sentry.captureException(urlWithBlacklistedUrl);
143+
Sentry.captureException(urlWithoutBlacklistedUrl);
144+
},
145+
function(sentryData) {
146+
if (debounceAssertEventCount(sentryData, 1, done)) {
147+
assert.equal(sentryData[0].exception.values[0].type, 'Error');
148+
assert.equal(sentryData[0].exception.values[0].value, 'pass');
149+
done();
150+
}
151+
}
152+
);
153+
});
104154
});
105155

106156
describe('API', function() {

0 commit comments

Comments
 (0)