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 25, 2024
1 parent 7c2aab9 commit 6e6348a
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ window.Sentry = Sentry;

Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
debug: true,
});
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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');
},
);
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,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 6e6348a

Please sign in to comment.