Skip to content

Commit

Permalink
Flake be gone
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiborza committed Aug 29, 2024
1 parent cf2c378 commit f5f59d5
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 79 deletions.
Original file line number Diff line number Diff line change
@@ -1,75 +1,15 @@
import * as Sentry from '@sentry/solidstart';
import type { ParentProps } from 'solid-js';
import { ErrorBoundary, createSignal, onMount } from 'solid-js';

const SentryErrorBoundary = Sentry.withSentryErrorBoundary(ErrorBoundary);

const [count, setCount] = createSignal(1);
const [caughtError, setCaughtError] = createSignal(false);

export default function ClientErrorPage() {
return (
<SampleErrorBoundary>
{caughtError() && (
<Throw error={`Error ${count()} thrown from Sentry ErrorBoundary in Solid Start E2E test app`} />
)}
<section class="bg-gray-100 text-gray-700 p-8">
<div class="flex flex-col items-start space-x-2">
<button
class="border rounded-lg px-2 mb-2 border-red-500 text-red-500 cursor-pointer"
id="caughtErrorBtn"
onClick={() => setCaughtError(true)}
>
Throw caught error
</button>
</div>
<div class="flex flex-col items-start space-x-2">
<button
class="border rounded-lg px-2 mb-2 border-red-500 text-red-500 cursor-pointer"
id="errorBtn"
onClick={() => {
throw new Error('Uncaught error thrown from Solid Start E2E test app');
}}
>
Throw uncaught error
</button>
</div>
</section>
</SampleErrorBoundary>
);
}

function Throw(props: { error: string }) {
onMount(() => {
throw new Error(props.error);
});
return null;
}

function SampleErrorBoundary(props: ParentProps) {
return (
<SentryErrorBoundary
fallback={(error, reset) => (
<section class="bg-gray-100 text-gray-700 p-8">
<h1 class="text-2xl font-bold">Error Boundary Fallback</h1>
<div class="flex items-center space-x-2 mb-4">
<code>{error.message}</code>
</div>
<button
id="errorBoundaryResetBtn"
class="border rounded-lg px-2 border-gray-900"
onClick={() => {
setCount(count() + 1);
setCaughtError(false);
reset();
}}
>
Reset
</button>
</section>
)}
>
{props.children}
</SentryErrorBoundary>
<div class="flex flex-col items-start space-x-2">
<button
class="border rounded-lg px-2 mb-2 border-red-500 text-red-500 cursor-pointer"
id="errorBtn"
onClick={() => {
throw new Error('Uncaught error thrown from Solid Start E2E test app');
}}
>
Throw uncaught error
</button>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import * as Sentry from '@sentry/solidstart';
import type { ParentProps } from 'solid-js';
import { ErrorBoundary, createSignal, onMount } from 'solid-js';

const SentryErrorBoundary = Sentry.withSentryErrorBoundary(ErrorBoundary);

const [count, setCount] = createSignal(1);
const [caughtError, setCaughtError] = createSignal(false);

export default function ErrorBoundaryTestPage() {
return (
<SampleErrorBoundary>
{caughtError() && (
<Throw error={`Error ${count()} thrown from Sentry ErrorBoundary in Solid Start E2E test app`} />
)}
<section class="bg-gray-100 text-gray-700 p-8">
<div class="flex flex-col items-start space-x-2">
<button
class="border rounded-lg px-2 mb-2 border-red-500 text-red-500 cursor-pointer"
id="caughtErrorBtn"
onClick={() => setCaughtError(true)}
>
Throw caught error
</button>
</div>
</section>
</SampleErrorBoundary>
);
}

function Throw(props: { error: string }) {
onMount(() => {
throw new Error(props.error);
});
return null;
}

function SampleErrorBoundary(props: ParentProps) {
return (
<SentryErrorBoundary
fallback={(error, reset) => (
<section class="bg-gray-100 text-gray-700 p-8">
<h1 class="text-2xl font-bold">Error Boundary Fallback</h1>
<div class="flex items-center space-x-2 mb-4">
<code>{error.message}</code>
</div>
<button
id="errorBoundaryResetBtn"
class="border rounded-lg px-2 border-gray-900"
onClick={() => {
setCount(count() + 1);
setCaughtError(false);
reset();
}}
>
Reset
</button>
</section>
)}
>
{props.children}
</SentryErrorBoundary>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export default function Home() {
<li>
<A href="/server-error">Server error</A>
</li>
<li>
<A href="/error-boundary">Error Boundary</A>
</li>
<li>
<A id="navLink" href="/users/5">
User 5
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, test } from '@playwright/test';
import { waitForError } from '@sentry-internal/test-utils';

test.skip('captures an exception', async ({ page }) => {
test('captures an exception', async ({ page }) => {
const errorEventPromise = waitForError('solidstart', errorEvent => {
return (
!errorEvent.type &&
Expand All @@ -10,7 +10,7 @@ test.skip('captures an exception', async ({ page }) => {
);
});

await page.goto('/client-error');
await page.goto('/error-boundary');
await page.locator('#caughtErrorBtn').click();
const errorEvent = await errorEventPromise;

Expand All @@ -27,11 +27,11 @@ test.skip('captures an exception', async ({ page }) => {
},
],
},
transaction: '/client-error',
transaction: '/error-boundary',
});
});

test.skip('captures a second exception after resetting the boundary', async ({ page }) => {
test('captures a second exception after resetting the boundary', async ({ page }) => {
const firstErrorEventPromise = waitForError('solidstart', errorEvent => {
return (
!errorEvent.type &&
Expand All @@ -40,7 +40,7 @@ test.skip('captures a second exception after resetting the boundary', async ({ p
);
});

await page.goto('/client-error');
await page.goto('/error-boundary');
await page.locator('#caughtErrorBtn').click();
const firstErrorEvent = await firstErrorEventPromise;

Expand All @@ -57,7 +57,7 @@ test.skip('captures a second exception after resetting the boundary', async ({ p
},
],
},
transaction: '/client-error',
transaction: '/error-boundary',
});

const secondErrorEventPromise = waitForError('solidstart', errorEvent => {
Expand Down Expand Up @@ -85,6 +85,6 @@ test.skip('captures a second exception after resetting the boundary', async ({ p
},
],
},
transaction: '/client-error',
transaction: '/error-boundary',
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test.describe('client-side errors', () => {
type: 'Error',
value: 'Uncaught error thrown from Solid Start E2E test app',
mechanism: {
type: 'instrument',
type: 'onerror',
handled: false,
},
},
Expand Down

0 comments on commit f5f59d5

Please sign in to comment.