Skip to content
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

test: Port loader tests from karma to playwright #11688

Merged
merged 1 commit into from
Apr 19, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Sentry.addBreadcrumb({
category: 'auth',
message: 'testing loader',
level: 'error',
});
Sentry.captureMessage('test');
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers';

sentryTest('should add breadcrumb to message', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });
const req = await waitForErrorRequestOnUrl(page, url);

const eventData = envelopeRequestParser(req);

expect(eventData.message).toBe('test');
expect(eventData.breadcrumbs?.length).toBe(1);
expect(eventData.breadcrumbs).toEqual([
{
category: 'auth',
level: 'error',
message: 'testing loader',
timestamp: expect.any(Number),
},
]);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Sentry.onLoad(function () {
Sentry.init({});
Sentry.addBreadcrumb({
category: 'auth',
message: 'testing loader',
level: 'error',
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sentry.captureMessage('test');
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers';

sentryTest('should add breadcrumb from onLoad callback to message', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });
const req = await waitForErrorRequestOnUrl(page, url);

const eventData = envelopeRequestParser(req);

expect(eventData.message).toBe('test');
expect(eventData.breadcrumbs?.length).toBe(1);
expect(eventData.breadcrumbs).toEqual([
{
category: 'auth',
level: 'error',
message: 'testing loader',
timestamp: expect.any(Number),
},
]);
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ sentryTest('captureException works', async ({ getLocalTestUrl, page }) => {

expect(eventData.message).toBe('Test exception');
});

sentryTest('should set SENTRY_SDK_SOURCE value', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });
const req = await waitForErrorRequestOnUrl(page, url);

const eventData = envelopeRequestParser(req);

expect(eventData.sdk?.packages?.[0].name).toBe('loader:@sentry/browser');
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,20 @@ sentryTest('captureException works inside of onLoad', async ({ getLocalTestUrl,

expect(eventData.message).toBe('Test exception');
});

sentryTest('should set SENTRY_SDK_SOURCE value', async ({ getLocalTestUrl, page }) => {
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
return route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ id: 'test-id' }),
});
});

const url = await getLocalTestUrl({ testDir: __dirname });
const req = await waitForErrorRequestOnUrl(page, url);

const eventData = envelopeRequestParser(req);

expect(eventData.sdk?.packages?.[0].name).toBe('loader:@sentry/browser');
});
43 changes: 0 additions & 43 deletions packages/browser/test/integration/suites/loader-specific.js

This file was deleted.

67 changes: 0 additions & 67 deletions packages/browser/test/integration/suites/loader.js

This file was deleted.

3 changes: 0 additions & 3 deletions packages/browser/test/integration/suites/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ function runVariant(variant) {
*/
{{ suites/onunhandledrejection.js }} // biome-ignore format: No trailing commas
{{ suites/builtins.js }} // biome-ignore format: No trailing commas
{{ suites/loader.js }} // biome-ignore format: No trailing commas
});
}

Expand All @@ -33,5 +32,3 @@ for (var idx in variants) {
runVariant(variants[idx]);
})();
}

{{ suites/loader-specific.js }} // biome-ignore format: No trailing commas
Loading