Skip to content

Commit

Permalink
test: Add test for sentry.event and sentry.transaction breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilogorek committed Feb 25, 2020
1 parent 9423447 commit fa80210
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/browser/test/integration/common/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function initSDK() {
}

// One of the tests use manually created breadcrumb without eventId and we want to let it through
if (breadcrumb.category === "sentry" && breadcrumb.event_id) {
if (breadcrumb.category.indexOf("sentry" === 0) && breadcrumb.event_id) {
return null;
}

Expand Down
41 changes: 39 additions & 2 deletions packages/browser/test/integration/suites/breadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe("breadcrumbs", function() {

it(
optional(
"should transform XMLHttpRequests to the Sentry store endpoint as sentry type breadcrumb",
"should transform XMLHttpRequests with events to the Sentry store endpoint as sentry.event type breadcrumb",
IS_LOADER
),
function() {
Expand All @@ -112,7 +112,44 @@ describe("breadcrumbs", function() {
return;
}
assert.equal(summary.breadcrumbs.length, 1);
assert.equal(summary.breadcrumbs[0].category, "sentry");
assert.equal(summary.breadcrumbs[0].category, "sentry.event");
assert.equal(summary.breadcrumbs[0].level, "warning");
assert.equal(summary.breadcrumbs[0].message, "someMessage");
});
}
);

it(
optional(
"should transform XMLHttpRequests with transactions to the Sentry store endpoint as sentry.transaction type breadcrumb",
IS_LOADER
),
function() {
return runInSandbox(sandbox, { manual: true }, function() {
var store =
document.location.protocol +
"//" +
document.location.hostname +
(document.location.port ? ":" + document.location.port : "") +
"/api/1/store/" +
"?sentry_key=1337";

var xhr = new XMLHttpRequest();
xhr.open("POST", store);
xhr.send(
'{"message":"someMessage","transaction":"wat","level":"warning"}'
);
waitForXHR(xhr, function() {
Sentry.captureMessage("test");
window.finalizeManualTest();
});
}).then(function(summary) {
// The async loader doesn't wrap XHR
if (IS_LOADER) {
return;
}
assert.equal(summary.breadcrumbs.length, 1);
assert.equal(summary.breadcrumbs[0].category, "sentry.transaction");
assert.equal(summary.breadcrumbs[0].level, "warning");
assert.equal(summary.breadcrumbs[0].message, "someMessage");
});
Expand Down

0 comments on commit fa80210

Please sign in to comment.