8000 chore(tests): Move unhandledrejection tests to their own file (#2427) · TGTGamer/sentry-javascript@7c16d93 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7c16d93

Browse files
chore(tests): Move unhandledrejection tests to their own file (getsentry#2427)
* move unhandledrejection tests to their own file * make new test file actually run Co-authored-by: Kamil Ogórek <kamil.ogorek@gmail.com>
1 parent cb31b28 commit 7c16d93

File tree

3 files changed

+271
-271
lines changed

3 files changed

+271
-271
lines changed

packages/browser/test/integration/suites/builtins.js

Lines changed: 0 additions & 271 deletions
Original file line numberDiff line numberDiff line change
@@ -43,277 +43,6 @@ describe("wrapped built-ins", function() {
4343
});
4444
});
4545

46-
describe("unhandledrejection", function() {
47-
it("should capture unhandledrejection with error", function() {
48-
return runInSandbox(sandbox, function() {
49-
if (supportsOnunhandledRejection()) {
50-
Promise.reject(new Error("test2"));
51-
} else {
52-
window.resolveTest({ window: window });
53-
}
54-
}).then(function(summary) {
55-
if (summary.window.supportsOnunhandledRejection()) {
56-
assert.equal(summary.events[0].exception.values[0].value, "test2");
57-
assert.equal(summary.events[0].exception.values[0].type, "Error");
58-
59-
// Of course Safari had to screw up here...
60-
if (!/Version\/\d.+Safari\/\d/.test(window.navigator.userAgent)) {
61-
assert.isAtLeast(
62-
summary.events[0].exception.values[0].stacktrace.frames.length,
63-
1
64-
);
65-
}
66-
assert.equal(
67-
summary.events[0].exception.values[0].mechanism.handled,
68-
false
69-
);
70-
assert.equal(
71-
summary.events[0].exception.values[0].mechanism.type,
72-
"onunhandledrejection"
73-
);
74-
}
75-
});
76-
});
77-
78-
it("should capture unhandledrejection with a string", function() {
79-
return runInSandbox(sandbox, function() {
80-
if (supportsOnunhandledRejection()) {
81-
Promise.reject("test");
82-
} else {
83-
window.resolveTest({ window: window });
84-
}
85-
}).then(function(summary) {
86-
if (summary.window.supportsOnunhandledRejection()) {
87-
// non-error rejections doesnt provide stacktraces so we can skip the assertion
88-
assert.equal(
89-
summary.events[0].exception.values[0].value,
90-
"Non-Error promise rejection captured with value: test"
91-
);
92-
assert.equal(
93-
summary.events[0].exception.values[0].type,
94-
"UnhandledRejection"
95-
);
96-
assert.equal(
97-
summary.events[0].exception.values[0].mechanism.handled,
98-
false
99-
);
100-
assert.equal(
101-
summary.events[0].exception.values[0].mechanism.type,
102-
"onunhandledrejection"
103-
);
104-
}
105-
});
106-
});
107-
108-
it("should capture unhandledrejection with a monster string", function() {
109-
return runInSandbox(sandbox, function() {
110-
if (supportsOnunhandledRejection()) {
111-
Promise.reject("test".repeat(100));
112-
} else {
113-
window.resolveTest({ window: window });
114-
}
115-
}).then(function(summary) {
116-
if (summary.window.supportsOnunhandledRejection()) {
117-
// non-error rejections doesnt provide stacktraces so we can skip the assertion
118-
assert.equal(summary.events[0].exception.values[0].value.length, 253);
119-
assert.include(
120-
summary.events[0].exception.values[0].value,
121-
"Non-Error promise rejection captured with value: "
122-
);
123-
assert.equal(
124-
summary.events[0].exception.values[0].type,
125-
"UnhandledRejection"
126-
);
127-
assert.equal(
128-
summary.events[0].exception.values[0].mechanism.handled,
129-
false
130-
);
131-
assert.equal(
132-
summary.events[0].exception.values[0].mechanism.type,
133-
"onunhandledrejection"
134-
);
135-
}
136-
});
137-
});
138-
139-
it("should capture unhandledrejection with an object", function() {
140-
return runInSandbox(sandbox, function() {
141-
if (supportsOnunhandledRejection()) {
142-
Promise.reject({ a: "b", b: "c", c: "d" });
143-
} else {
144-
window.resolveTest({ window: window });
145-
}
146-
}).then(function(summary) {
147-
if (summary.window.supportsOnunhandledRejection()) {
148-
// non-error rejections doesnt provide stacktraces so we can skip the assertion
149-
assert.equal(
150-
summary.events[0].exception.values[0].value,
151-
"Non-Error promise rejection captured with keys: a, b, c"
152-
);
153-
assert.equal(
154-
summary.events[0].exception.values[0].type,
155-
"UnhandledRejection"
156-
);
157-
assert.equal(
158-
summary.events[0].exception.values[0].mechanism.handled,
159-
false
160-
);
161-
assert.equal(
162-
summary.events[0].exception.values[0].mechanism.type,
163-
"onunhandledrejection"
164-
);
165-
}
166-
});
167-
});
168-
169-
it("should capture unhandledrejection with an monster object", function() {
170-
return runInSandbox(sandbox, function() {
171-
if (supportsOnunhandledRejection()) {
172-
var a = {
173-
a: "1".repeat("100"),
174-
b: "2".repeat("100"),
175-
c: "3".repeat("100"),
176-
};
177-
a.d = a.a;
178-
a.e = a;
179-
Promise.reject(a);
180-
} else {
181-
window.resolveTest({ window: window });
182-
}
183-
}).then(function(summary) {
184-
if (summary.window.supportsOnunhandledRejection()) {
185-
// non-error rejections doesnt provide stacktraces so we can skip the assertion
186-
assert.equal(
187-
summary.events[0].exception.values[0].value,
188-
"Non-Error promise rejection captured with keys: a, b, c, d, e"
189-
);
190-
assert.equal(
191-
summary.events[0].exception.values[0].type,
192-
"UnhandledRejection"
193-
);
194-
assert.equal(
195-
summary.events[0].exception.values[0].mechanism.handled,
196-
false
197-
);
198-
assert.equal(
199-
summary.events[0].exception.values[0].mechanism.type,
200-
"onunhandledrejection"
201-
);
202-
}
203-
});
204-
});
205-
206-
it("should capture unhandledrejection with a number", function() {
207-
return runInSandbox(sandbox, function() {
208-
if (supportsOnunhandledRejection()) {
209-
Promise.reject(1337);
210-
} else {
211-
window.resolveTest({ window: window });
212-
}
213-
}).then(function(summary) {
214-
if (summary.window.supportsOnunhandledRejection()) {
215-
// non-error rejections doesnt provide stacktraces so we can skip the assertion
216-
assert.equal(
217-
summary.events[0].exception.values[0].value,
218-
"Non-Error promise rejection captured with value: 1337"
219-
);
220-
assert.equal(
221-
summary.events[0].exception.values[0].type,
222-
"UnhandledRejection"
223-
);
224-
assert.equal(
225-
summary.events[0].exception.values[0].mechanism.handled,
226-
false
227-
);
228-
assert.equal(
229-
summary.events[0].exception.values[0].mechanism.type,
230-
"onunhandledrejection"
231-
);
232-
}
233-
});
234-
});
235-
236-
it("should capture unhandledrejection with null", function() {
237-
return runInSandbox(sandbox, function() {
238-
if (supportsOnunhandledRejection()) {
239-
Promise.reject(null);
240-
} else {
241-
window.resolveTest({ window: window });
242-
}
243-
}).then(function(summary) {
244-
if (summary.window.supportsOnunhandledRejection()) {
245-
// non-error rejections doesnt provide stacktraces so we can skip the assertion
246-
assert.equal(
247-
summary.events[0].exception.values[0].value,
248-
"Non-Error promise rejection captured with value: null"
249-
);
250-
assert.equal(
251-
summary.events[0].exception.values[0].type,
252-
"UnhandledRejection"
253-
);
254-
assert.equal(
255-
summary.events[0].exception.values[0].mechanism.handled,
256-
false
257-
);
258-
assert.equal(
259-
summary.events[0].exception.values[0].mechanism.type,
260-
"onunhandledrejection"
261-
);
262-
}
263-
});
264-
});
265-
266-
it("should capture unhandledrejection with an undefined", function() {
267-
return runInSandbox(sandbox, function() {
268-
if (supportsOnunhandledRejection()) {
269-
Promise.reject(undefined);
270-
} else {
271-
window.resolveTest({ window: window });
272-
}
273-
}).then(function(summary) {
274-
if (summary.window.supportsOnunhandledRejection()) {
275-
// non-error rejections doesnt provide stacktraces so we can skip the assertion
276-
assert.equal(
277-
summary.events[0].exception.values[0].value,
278-
"Non-Error promise rejection captured with value: undefined"
279-
);
280-
assert.equal(
281-
summary.events[0].exception.values[0].type,
282-
"UnhandledRejection"
283-
);
284-
assert.equal(
285-
summary.events[0].exception.values[0].mechanism.handled,
286-
false
287-
);
288-
assert.equal(
289-
summary.events[0].exception.values[0].mechanism.type,
290-
"onunhandledrejection"
291-
);
292-
}
293-
});
294-
});
295-
296-
it("should skip our own failed requests that somehow bubbled-up to unhandledrejection handler", function() {
297-
return runInSandbox(sandbox, function() {
298-
if (supportsOnunhandledRejection()) {
299-
Promise.reject({
300-
__sentry_own_request__: true,
301-
});
302-
Promise.reject({
303-
__sentry_own_request__: false,
304-
});
305-
Promise.reject({});
306-
} else {
307-
window.resolveTest({ window: window });
308-
}
309-
}).then(function(summary) {
310-
if (summary.window.supportsOnunhandledRejection()) {
311-
assert.equal(summary.events.length, 2);
312-
}
313-
});
314-
});
315-
});
316-
31746
it("should capture exceptions inside setTimeout", function() {
31847
return runInSandbox(sandbox, function() {
31948
setTimeout(function() {

0 commit comments

Comments
 (0)
0