Skip to content

Commit

Permalink
Skip runScriptInSandbox tests on webkit.
Browse files Browse the repository at this point in the history
  • Loading branch information
onurtemizkan committed Apr 23, 2024
1 parent 094909f commit eb9b51c
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 23 deletions.
Expand Up @@ -6,7 +6,12 @@ import { getFirstSentryEnvelopeRequest, runScriptInSandbox } from '../../../../.

sentryTest(
'should catch onerror calls with non-string first argument gracefully',
async ({ getLocalTestPath, page }) => {
async ({ getLocalTestPath, page, browserName }) => {
if (browserName === 'webkit') {
// This test fails on Webkit as erros thrown from `runScriptInSandbox` are Script Errors and skipped by Sentry
sentryTest.skip();
}

const url = await getLocalTestPath({ testDir: __dirname });

await page.goto(url);
Expand Down
Expand Up @@ -6,7 +6,12 @@ import { getMultipleSentryEnvelopeRequests, runScriptInSandbox } from '../../../

sentryTest(
'should NOT catch an exception already caught [but rethrown] via Sentry.captureException',
async ({ getLocalTestPath, page }) => {
async ({ getLocalTestPath, page, browserName }) => {
if (browserName === 'webkit') {
// This test fails on Webkit as erros thrown from `runScriptInSandbox` are Script Errors and skipped by Sentry
sentryTest.skip();
}

const url = await getLocalTestPath({ testDir: __dirname });

await page.goto(url);
Expand Down
Expand Up @@ -4,7 +4,12 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest, runScriptInSandbox } from '../../../../../utils/helpers';

sentryTest('should catch syntax errors', async ({ getLocalTestPath, page }) => {
sentryTest('should catch syntax errors', async ({ getLocalTestPath, page, browserName }) => {
if (browserName === 'webkit') {
// This test fails on Webkit as erros thrown from `runScriptInSandbox` are Script Errors and skipped by Sentry
sentryTest.skip();
}

const url = await getLocalTestPath({ testDir: __dirname });

await page.goto(url);
Expand Down
Expand Up @@ -4,7 +4,12 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest, runScriptInSandbox } from '../../../../../utils/helpers';

sentryTest('should catch thrown errors', async ({ getLocalTestPath, page }) => {
sentryTest('should catch thrown errors', async ({ getLocalTestPath, page, browserName }) => {
if (browserName === 'webkit') {
// This test fails on Webkit as erros thrown from `runScriptInSandbox` are Script Errors and skipped by Sentry
sentryTest.skip();
}

const url = await getLocalTestPath({ testDir: __dirname });

await page.goto(url);
Expand Down
Expand Up @@ -4,7 +4,12 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest, runScriptInSandbox } from '../../../../../utils/helpers';

sentryTest('should catch thrown objects', async ({ getLocalTestPath, page }) => {
sentryTest('should catch thrown objects', async ({ getLocalTestPath, page, browserName }) => {
if (browserName === 'webkit') {
// This test fails on Webkit as erros thrown from `runScriptInSandbox` are Script Errors and skipped by Sentry
sentryTest.skip();
}

const url = await getLocalTestPath({ testDir: __dirname });

await page.goto(url);
Expand Down
Expand Up @@ -4,7 +4,12 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest, runScriptInSandbox } from '../../../../../utils/helpers';

sentryTest('should catch thrown strings', async ({ getLocalTestPath, page }) => {
sentryTest('should catch thrown strings', async ({ getLocalTestPath, page, browserName }) => {
if (browserName === 'webkit') {
// This test fails on Webkit as erros thrown from `runScriptInSandbox` are Script Errors and skipped by Sentry
sentryTest.skip();
}

const url = await getLocalTestPath({ testDir: __dirname });

await page.goto(url);
Expand Down
Expand Up @@ -8,19 +8,26 @@ import {
shouldSkipTracingTest,
} from '../../../../utils/helpers';

sentryTest('should capture an error within a sync startSpan callback', async ({ getLocalTestPath, page }) => {
if (shouldSkipTracingTest()) {
sentryTest.skip();
}
sentryTest(
'should capture an error within a sync startSpan callback',
async ({ getLocalTestPath, page, browserName }) => {
if (browserName === 'webkit') {
// This test fails on Webkit as erros thrown from `runScriptInSandbox` are Script Errors and skipped by Sentry
sentryTest.skip();
}

const url = await getLocalTestPath({ testDir: __dirname });
if (shouldSkipTracingTest()) {
sentryTest.skip();
}

await page.goto(url);
const url = await getLocalTestPath({ testDir: __dirname });

const errorEventsPromise = getMultipleSentryEnvelopeRequests<Event>(page, 2);
await page.goto(url);

runScriptInSandbox(page, {
content: `
const errorEventsPromise = getMultipleSentryEnvelopeRequests<Event>(page, 2);

runScriptInSandbox(page, {
content: `
function run() {
Sentry.startSpan({ name: 'parent_span' }, () => {
throw new Error('Sync Error');
Expand All @@ -29,13 +36,14 @@ sentryTest('should capture an error within a sync startSpan callback', async ({
setTimeout(run);
`,
});
});

const events = await errorEventsPromise;
const events = await errorEventsPromise;

const txn = events.find(event => event.type === 'transaction');
const err = events.find(event => !event.type);
const txn = events.find(event => event.type === 'transaction');
const err = events.find(event => !event.type);

expect(txn).toMatchObject({ transaction: 'parent_span' });
expect(err?.exception?.values?.[0]?.value).toBe('Sync Error');
});
expect(txn).toMatchObject({ transaction: 'parent_span' });
expect(err?.exception?.values?.[0]?.value).toBe('Sync Error');
},
);
Expand Up @@ -9,7 +9,12 @@ import {

sentryTest(
'should put the pageload transaction name onto an error event caught during pageload',
async ({ getLocalTestPath, page }) => {
async ({ getLocalTestPath, page, browserName }) => {
if (browserName === 'webkit') {
// This test fails on Webkit as erros thrown from `runScriptInSandbox` are Script Errors and skipped by Sentry
sentryTest.skip();
}

if (shouldSkipTracingTest()) {
sentryTest.skip();
}
Expand Down
3 changes: 3 additions & 0 deletions dev-packages/browser-integration-tests/utils/helpers.ts
Expand Up @@ -139,6 +139,9 @@ export const countEnvelopes = async (

/**
* Run script inside the test environment.
* This is useful for throwing errors in the test environment.
*
* Errors thrown from this function are not guaranteed to be captured by Sentry, especially in Webkit.
*
* @param {Page} page
* @param {{ path?: string; content?: string }} impl
Expand Down

0 comments on commit eb9b51c

Please sign in to comment.