Skip to content

Commit c68f1ad

Browse files
authored
test: Refactor webpack E2E tests to avoid sending to Sentry (getsentry#12312)
Part of getsentry#11910
1 parent b1708d0 commit c68f1ad

14 files changed

+62
-208
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { browserTracingIntegration, captureException, init } from '@sentry/browser';
1+
import { browserTracingIntegration, init } from '@sentry/browser';
22

33
init({
44
dsn: process.env.E2E_TEST_DSN,
55
integrations: [browserTracingIntegration()],
6+
tunnel: 'http://localhost:3031',
67
});
78

89
setTimeout(() => {
9-
const eventId = captureException(new Error('I am an error!'));
10-
window.capturedExceptionId = eventId;
10+
throw new Error('I am an error!');
1111
}, 2000);

dev-packages/e2e-tests/test-applications/webpack-4/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"devDependencies": {
1111
"@playwright/test": "^1.44.1",
12+
"@sentry-internal/test-utils": "link:../../../test-utils",
1213
"@sentry/browser": "latest || *",
1314
"webpack": "^4.47.0",
1415
"terser-webpack-plugin": "^4.2.3",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { getPlaywrightConfig } from '@sentry-internal/test-utils';
2+
3+
const config = getPlaywrightConfig({
4+
startCommand: 'pnpm start',
5+
});
6+
7+
export default config;

dev-packages/e2e-tests/test-applications/webpack-4/playwright.config.ts

Lines changed: 0 additions & 70 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { startEventProxyServer } from '@sentry-internal/test-utils';
2+
3+
startEventProxyServer({
4+
port: 3031,
5+
proxyServerName: 'webpack-4',
6+
});

dev-packages/e2e-tests/test-applications/webpack-4/tests/behaviour-test.spec.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { expect, test } from '@playwright/test';
2+
import { waitForError } from '@sentry-internal/test-utils';
3+
4+
test('Captures an exception', async ({ page }) => {
5+
const eventPromise = waitForError('webpack-4', event => {
6+
return event.exception?.values?.[0].value === 'I am an error!';
7+
});
8+
await page.goto('/');
9+
10+
const errorEvent = await eventPromise;
11+
12+
expect(errorEvent.exception?.values?.[0].value).toBe('I am an error!');
13+
expect(errorEvent.transaction).toBe('/');
14+
});
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { browserTracingIntegration, captureException, init } from '@sentry/browser';
1+
import { browserTracingIntegration, init } from '@sentry/browser';
22

33
init({
44
dsn: process.env.E2E_TEST_DSN,
55
integrations: [browserTracingIntegration()],
6+
tunnel: 'http://localhost:3031',
67
});
78

89
setTimeout(() => {
9-
const eventId = captureException(new Error('I am an error!'));
10-
window.capturedExceptionId = eventId;
10+
throw new Error('I am an error!');
1111
}, 2000);

dev-packages/e2e-tests/test-applications/webpack-5/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"devDependencies": {
1111
"@playwright/test": "^1.44.1",
12+
"@sentry-internal/test-utils": "link:../../../test-utils",
1213
"@sentry/browser": "latest || *",
1314
"webpack": "^5.91.0",
1415
"terser-webpack-plugin": "^5.3.10",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { getPlaywrightConfig } from '@sentry-internal/test-utils';
2+
3+
const config = getPlaywrightConfig({
4+
startCommand: 'pnpm start',
5+
});
6+
7+
export default config;

dev-packages/e2e-tests/test-applications/webpack-5/playwright.config.ts

Lines changed: 0 additions & 70 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { startEventProxyServer } from '@sentry-internal/test-utils';
2+
3+
startEventProxyServer({
4+
port: 3031,
5+
proxyServerName: 'webpack-5',
6+
});

dev-packages/e2e-tests/test-applications/webpack-5/tests/behaviour-test.spec.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { expect, test } from '@playwright/test';
2+
import { waitForError } from '@sentry-internal/test-utils';
3+
4+
test('Captures an exception', async ({ page }) => {
5+
const eventPromise = waitForError('webpack-5', event => {
6+
return event.exception?.values?.[0].value === 'I am an error!';
7+
});
8+
await page.goto('/');
9+
10+
const errorEvent = await eventPromise;
11+
12+
expect(errorEvent.exception?.values?.[0].value).toBe('I am an error!');
13+
expect(errorEvent.transaction).toBe('/');
14+
});

0 commit comments

Comments
 (0)