Skip to content

test(browser): Add integration tests for addBreadcrumb. #4353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2021
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
1 change: 0 additions & 1 deletion packages/integration-tests/suites/demo/tmp/subject.js

This file was deleted.

12 changes: 0 additions & 12 deletions packages/integration-tests/suites/demo/tmp/test.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Sentry.addBreadcrumb({});

Sentry.captureMessage('test_empty_obj');
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';

sentryTest(
'should add an empty breadcrumb initialized with a timestamp, when an empty object is given',
async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });

const eventData = await getSentryRequest(page, url);

expect(eventData.breadcrumbs).toHaveLength(1);
expect(eventData.breadcrumbs?.[0]).toMatchObject({
timestamp: expect.any(Number),
});

expect(eventData.message).toBe('test_empty_obj');
},
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Sentry.addBreadcrumb({
category: 'foo',
message: 'bar',
level: 'baz',
});

Sentry.addBreadcrumb({
category: 'qux',
});

Sentry.captureMessage('test_multi_breadcrumbs');
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';

sentryTest('should add multiple breadcrumbs', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });

const eventData = await getSentryRequest(page, url);

expect(eventData.breadcrumbs).toHaveLength(2);
expect(eventData.breadcrumbs?.[0]).toMatchObject({
category: 'foo',
message: 'bar',
level: 'baz',
});
expect(eventData.breadcrumbs?.[1]).toMatchObject({
category: 'qux',
});
expect(eventData.message).toBe('test_multi_breadcrumbs');
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Sentry.addBreadcrumb({
category: 'foo',
message: 'bar',
level: 'baz',
});

Sentry.captureMessage('test');
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';

sentryTest('should add a simple breadcrumb', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });

const eventData = await getSentryRequest(page, url);

expect(eventData.breadcrumbs).toHaveLength(1);
expect(eventData.breadcrumbs?.[0]).toMatchObject({
category: 'foo',
message: 'bar',
level: 'baz',
});
expect(eventData.message).toBe('test');
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Sentry.addBreadcrumb();

Sentry.captureMessage('test_undefined_arg');
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';

sentryTest(
'should add an empty breadcrumb initialized with a timestamp, when no argument is given',
async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });

const eventData = await getSentryRequest(page, url);

expect(eventData.breadcrumbs).toHaveLength(1);
expect(eventData.breadcrumbs?.[0]).toMatchObject({
timestamp: expect.any(Number),
});

expect(eventData.message).toBe('test_undefined_arg');
},
);