forked from getsentry/sentry-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
55 lines (52 loc) · 2.2 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
describe("config", function() {
it("should allow to ignore specific errors", function() {
return runInSandbox(sandbox, function() {
Sentry.captureException(new Error("foo"));
Sentry.captureException(new Error("ignoreErrorTest"));
Sentry.captureException(new Error("bar"));
}).then(function(summary) {
assert.equal(summary.events[0].exception.values[0].type, "Error");
assert.equal(summary.events[0].exception.values[0].value, "foo");
assert.equal(summary.events[1].exception.values[0].type, "Error");
assert.equal(summary.events[1].exception.values[0].value, "bar");
});
});
it("should allow to ignore specific urls", function() {
return runInSandbox(sandbox, function() {
/**
* We always filter on the caller, not the cause of the error
*
* > foo.js file called a function in bar.js
* > bar.js file called a function in baz.js
* > baz.js threw an error
*
* foo.js is excluded in the `init` call (init.js), thus we filter it
* */
var urlWithExcludedUrl = new Error("filter");
urlWithExcludedUrl.stack =
"Error: bar\n" +
" at http://localhost:5000/foo.js:7:19\n" +
" at bar(http://localhost:5000/bar.js:2:3)\n" +
" at baz(http://localhost:5000/baz.js:2:9)\n";
/**
* > foo-pass.js file called a function in bar-pass.js
* > bar-pass.js file called a function in baz-pass.js
* > baz-pass.js threw an error
*
* foo-pass.js is *not* excluded in the `init` call (init.js), thus we don't filter it
* */
var urlWithoutExcludedUrl = new Error("pass");
urlWithoutExcludedUrl.stack =
"Error: bar\n" +
" at http://localhost:5000/foo-pass.js:7:19\n" +
" at bar(http://localhost:5000/bar-pass.js:2:3)\n" +
" at baz(http://localhost:5000/baz-pass.js:2:9)\n";
Sentry.captureException(urlWithExcludedUrl);
Sentry.captureException(urlWithoutExcludedUrl);
}).then(function(summary) {
assert.lengthOf(summary.events, 1);
assert.equal(summary.events[0].exception.values[0].type, "Error");
assert.equal(summary.events[0].exception.values[0].value, "pass");
});
});
});