Skip to content

Commit

Permalink
test: Refactor webpack E2E tests to avoid sending to Sentry (#12312)
Browse files Browse the repository at this point in the history
Part of #11910
  • Loading branch information
mydea authored and c298lee committed Jun 4, 2024
1 parent b4505d8 commit 4772147
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 208 deletions.
6 changes: 3 additions & 3 deletions dev-packages/e2e-tests/test-applications/webpack-4/entry.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { browserTracingIntegration, captureException, init } from '@sentry/browser';
import { browserTracingIntegration, init } from '@sentry/browser';

init({
dsn: process.env.E2E_TEST_DSN,
integrations: [browserTracingIntegration()],
tunnel: 'http://localhost:3031',
});

setTimeout(() => {
const eventId = captureException(new Error('I am an error!'));
window.capturedExceptionId = eventId;
throw new Error('I am an error!');
}, 2000);
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"devDependencies": {
"@playwright/test": "^1.44.1",
"@sentry-internal/test-utils": "link:../../../test-utils",
"@sentry/browser": "latest || *",
"webpack": "^4.47.0",
"terser-webpack-plugin": "^4.2.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { getPlaywrightConfig } from '@sentry-internal/test-utils';

const config = getPlaywrightConfig({
startCommand: 'pnpm start',
});

export default config;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { startEventProxyServer } from '@sentry-internal/test-utils';

startEventProxyServer({
port: 3031,
proxyServerName: 'webpack-4',
});

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { expect, test } from '@playwright/test';
import { waitForError } from '@sentry-internal/test-utils';

test('Captures an exception', async ({ page }) => {
const eventPromise = waitForError('webpack-4', event => {
return event.exception?.values?.[0].value === 'I am an error!';
});
await page.goto('/');

const errorEvent = await eventPromise;

expect(errorEvent.exception?.values?.[0].value).toBe('I am an error!');
expect(errorEvent.transaction).toBe('/');
});
6 changes: 3 additions & 3 deletions dev-packages/e2e-tests/test-applications/webpack-5/entry.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { browserTracingIntegration, captureException, init } from '@sentry/browser';
import { browserTracingIntegration, init } from '@sentry/browser';

init({
dsn: process.env.E2E_TEST_DSN,
integrations: [browserTracingIntegration()],
tunnel: 'http://localhost:3031',
});

setTimeout(() => {
const eventId = captureException(new Error('I am an error!'));
window.capturedExceptionId = eventId;
throw new Error('I am an error!');
}, 2000);
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"devDependencies": {
"@playwright/test": "^1.44.1",
"@sentry-internal/test-utils": "link:../../../test-utils",
"@sentry/browser": "latest || *",
"webpack": "^5.91.0",
"terser-webpack-plugin": "^5.3.10",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { getPlaywrightConfig } from '@sentry-internal/test-utils';

const config = getPlaywrightConfig({
startCommand: 'pnpm start',
});

export default config;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { startEventProxyServer } from '@sentry-internal/test-utils';

startEventProxyServer({
port: 3031,
proxyServerName: 'webpack-5',
});

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { expect, test } from '@playwright/test';
import { waitForError } from '@sentry-internal/test-utils';

test('Captures an exception', async ({ page }) => {
const eventPromise = waitForError('webpack-5', event => {
return event.exception?.values?.[0].value === 'I am an error!';
});
await page.goto('/');

const errorEvent = await eventPromise;

expect(errorEvent.exception?.values?.[0].value).toBe('I am an error!');
expect(errorEvent.transaction).toBe('/');
});

0 comments on commit 4772147

Please sign in to comment.