Skip to content

Commit 5d249bc

Browse files
committed
fix bundle tests
1 parent 5fc4f33 commit 5d249bc

File tree

3 files changed

+28
-8
lines changed
  • dev-packages/browser-integration-tests

3 files changed

+28
-8
lines changed

dev-packages/browser-integration-tests/suites/manual-client/skip-init-browser-extension/test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expect } from '@playwright/test';
22
import { sentryTest } from '../../../utils/fixtures';
3+
import { hasDebugLogs } from '../../../utils/helpers';
34

45
sentryTest(
56
'should not initialize when inside a Firefox/Safari browser extension',
@@ -18,9 +19,14 @@ sentryTest(
1819
});
1920

2021
expect(isInitialized).toEqual(false);
21-
expect(errorLogs.length).toEqual(1);
22-
expect(errorLogs[0]).toEqual(
23-
'[Sentry] You cannot run Sentry this way in a browser extension, check: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
24-
);
22+
23+
if (hasDebugLogs()) {
24+
expect(errorLogs.length).toEqual(1);
25+
expect(errorLogs[0]).toEqual(
26+
'[Sentry] You cannot run Sentry this way in a browser extension, check: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
27+
);
28+
} else {
29+
expect(errorLogs.length).toEqual(0);
30+
}
2531
},
2632
);

dev-packages/browser-integration-tests/suites/manual-client/skip-init-chrome-extension/test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expect } from '@playwright/test';
22
import { sentryTest } from '../../../utils/fixtures';
3+
import { hasDebugLogs } from '../../../utils/helpers';
34

45
sentryTest('should not initialize when inside a Chrome browser extension', async ({ getLocalTestUrl, page }) => {
56
const errorLogs: string[] = [];
@@ -16,8 +17,13 @@ sentryTest('should not initialize when inside a Chrome browser extension', async
1617
});
1718

1819
expect(isInitialized).toEqual(false);
19-
expect(errorLogs.length).toEqual(1);
20-
expect(errorLogs[0]).toEqual(
21-
'[Sentry] You cannot run Sentry this way in a browser extension, check: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
22-
);
20+
21+
if (hasDebugLogs()) {
22+
expect(errorLogs.length).toEqual(1);
23+
expect(errorLogs[0]).toEqual(
24+
'[Sentry] You cannot run Sentry this way in a browser extension, check: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
25+
);
26+
} else {
27+
expect(errorLogs.length).toEqual(0);
28+
}
2329
});

dev-packages/browser-integration-tests/utils/helpers.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,14 @@ export function shouldSkipFeatureFlagsTest(): boolean {
302302
return bundle != null && !bundle.includes('esm') && !bundle.includes('cjs');
303303
}
304304

305+
/**
306+
* Returns true if the current bundle has debug logs.
307+
*/
308+
export function hasDebugLogs(): boolean {
309+
const bundle = process.env.PW_BUNDLE;
310+
return !bundle?.includes('min');
311+
}
312+
305313
/**
306314
* Waits until a number of requests matching urlRgx at the given URL arrive.
307315
* If the timeout option is configured, this function will abort waiting, even if it hasn't received the configured

0 commit comments

Comments
 (0)