-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathpinia.test.ts
35 lines (25 loc) · 1.1 KB
/
pinia.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { expect, test } from '@playwright/test';
import { waitForError } from '@sentry-internal/test-utils';
test('sends pinia action breadcrumbs and state context', async ({ page }) => {
await page.goto('/cart');
await page.locator('#item-input').fill('item');
await page.locator('#item-add').click();
const errorPromise = waitForError('vue-3', async errorEvent => {
return errorEvent?.exception?.values?.[0].value === 'This is an error';
});
await page.locator('#throw-error').click();
const error = await errorPromise;
expect(error).toBeTruthy();
expect(error.breadcrumbs?.length).toBeGreaterThan(0);
const actionBreadcrumb = error.breadcrumbs?.find(breadcrumb => breadcrumb.category === 'action');
expect(actionBreadcrumb).toBeDefined();
expect(actionBreadcrumb?.message).toBe('Transformed: addItem');
expect(actionBreadcrumb?.level).toBe('info');
const stateContext = error.contexts?.state?.state;
expect(stateContext).toBeDefined();
expect(stateContext?.type).toBe('pinia');
expect(stateContext?.value).toEqual({
transformed: true,
rawItems: ['item'],
});
});