Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<script setup>
import ErrorButton from '../components/ErrorButton.vue';

const catchErr = () => {
console.log('Additional functionality in NuxtErrorBoundary');
}
</script>

<template>
<ErrorButton id="errorBtn" error-text="Error thrown from Nuxt-3 E2E test app"/>
<ErrorButton id="errorBtn2" error-text="Another Error thrown from Nuxt-3 E2E test app"/>
</template>



<NuxtErrorBoundary @error="catchErr">
<ErrorButton id="error-in-error-boundary" error-text="Error thrown in Error Boundary"/>
</NuxtErrorBoundary>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,47 @@ test.describe('client-side errors', async () => {
});
});

test('captures error thrown in NuxtErrorBoundary', async ({ page }) => {
const errorPromise = waitForError('nuxt-3', async errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === 'Error thrown in Error Boundary';
});

await page.goto(`/client-error`);
await page.locator('#error-in-error-boundary').click();

const error = await errorPromise;

const expectedBreadcrumb = {
category: 'console',
message: 'Additional functionality in NuxtErrorBoundary',
};

const matchingBreadcrumb = error.breadcrumbs.find(
(breadcrumb: { category: string; message: string }) =>
breadcrumb.category === expectedBreadcrumb.category && breadcrumb.message === expectedBreadcrumb.message,
);

expect(matchingBreadcrumb).toBeTruthy();
expect(matchingBreadcrumb?.category).toBe(expectedBreadcrumb.category);
expect(matchingBreadcrumb?.message).toBe(expectedBreadcrumb.message);

expect(error.transaction).toEqual('/client-error');
expect(error.sdk.name).toEqual('sentry.javascript.nuxt');
expect(error).toMatchObject({
exception: {
values: [
{
type: 'Error',
value: 'Error thrown in Error Boundary',
mechanism: {
handled: false,
},
},
],
},
});
});

test('shows parametrized route on button error', async ({ page }) => {
const errorPromise = waitForError('nuxt-3', async errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === 'Error thrown from Param Route Button';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<script setup>
import ErrorButton from '../components/ErrorButton.vue';

const catchErr = () => {
console.log('Additional functionality in NuxtErrorBoundary');
}
</script>

<template>
<ErrorButton id="errorBtn" error-text="Error thrown from Nuxt-4 E2E test app"/>
<ErrorButton id="errorBtn2" error-text="Another Error thrown from Nuxt-4 E2E test app"/>
</template>



<NuxtErrorBoundary @error="catchErr">
<ErrorButton id="error-in-error-boundary" error-text="Error thrown in Error Boundary"/>
</NuxtErrorBoundary>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,47 @@ test.describe('client-side errors', async () => {
});
});

test('captures error thrown in NuxtErrorBoundary', async ({ page }) => {
const errorPromise = waitForError('nuxt-4', async errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === 'Error thrown in Error Boundary';
});

await page.goto(`/client-error`);
await page.locator('#error-in-error-boundary').click();

const error = await errorPromise;

const expectedBreadcrumb = {
category: 'console',
message: 'Additional functionality in NuxtErrorBoundary',
};

const matchingBreadcrumb = error.breadcrumbs.find(
(breadcrumb: { category: string; message: string }) =>
breadcrumb.category === expectedBreadcrumb.category && breadcrumb.message === expectedBreadcrumb.message,
);

expect(matchingBreadcrumb).toBeTruthy();
expect(matchingBreadcrumb?.category).toBe(expectedBreadcrumb.category);
expect(matchingBreadcrumb?.message).toBe(expectedBreadcrumb.message);

expect(error.transaction).toEqual('/client-error');
expect(error.sdk.name).toEqual('sentry.javascript.nuxt');
expect(error).toMatchObject({
exception: {
values: [
{
type: 'Error',
value: 'Error thrown in Error Boundary',
mechanism: {
handled: false,
},
},
],
},
});
});

test('shows parametrized route on button error', async ({ page }) => {
const errorPromise = waitForError('nuxt-4', async errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === 'Error thrown from Param Route Button';
Expand Down
Loading