Skip to content
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
14 changes: 9 additions & 5 deletions packages/browser/src/integrations/breadcrumbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,18 @@ export class Breadcrumbs implements Integration {
if (args[0] === false) {
breadcrumbData.message = `Assertion failed: ${safeJoin(args.slice(1), ' ') || 'console.assert'}`;
breadcrumbData.data.extra.arguments = normalize(args.slice(1), 3);
Breadcrumbs.addBreadcrumb(breadcrumbData, {
input: args,
level,
});
}
} else {
Breadcrumbs.addBreadcrumb(breadcrumbData, {
input: args,
level,
});
}

Breadcrumbs.addBreadcrumb(breadcrumbData, {
input: args,
level,
});

// this fails for some browsers. :(
if (originalConsoleLevel) {
Function.prototype.apply.call(originalConsoleLevel, global.console, args);
Expand Down
6 changes: 6 additions & 0 deletions packages/browser/test/integration/subjects/console-logs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
console.log("One");
console.warn("Two", { a: 1 });
console.error("Error 2", { b: { c: [] } });

// Passed assertions _should not_ be captured
console.assert(1 + 1 === 2, "math works");
// Failed assertions _should_ be captured
console.assert(1 + 1 === 3, "math broke");

function a() {
throw new Error("Error thrown 3");
}
Expand Down
13 changes: 10 additions & 3 deletions packages/browser/test/integration/suites/breadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ describe("breadcrumbs", function() {
}
);

it("should add breadcrumbs on thrown errors", function() {
it("should capture console breadcrumbs", function() {
return runInSandbox(sandbox, { manual: true }, function() {
window.allowConsoleBreadcrumbs = true;
var logs = document.createElement("script");
Expand All @@ -726,8 +726,15 @@ describe("breadcrumbs", function() {
// The async loader doesn't capture breadcrumbs, but we should receive the event without them
assert.lengthOf(summary.events, 1);
} else {
assert.ok(summary.breadcrumbs);
assert.lengthOf(summary.breadcrumbs, 3);
if ("assert" in console) {
assert.lengthOf(summary.breadcrumbs, 4);
assert.deepEqual(summary.breadcrumbs[3].data.extra.arguments, [
"math broke",
]);
} else {
assert.lengthOf(summary.breadcrumbs, 3);
}

assert.deepEqual(summary.breadcrumbs[0].data.extra.arguments, ["One"]);
assert.deepEqual(summary.breadcrumbs[1].data.extra.arguments, [
"Two",
Expand Down