|
| 1 | +import { expect } from '@playwright/test'; |
| 2 | +import type { Event } from '@sentry/types'; |
| 3 | + |
| 4 | +import { sentryTest } from '../../../utils/fixtures'; |
| 5 | +import { getFirstSentryEnvelopeRequest } from '../../../utils/helpers'; |
| 6 | + |
| 7 | +sentryTest('allows to setup a client manually & capture exceptions', async ({ getLocalTestUrl, page }) => { |
| 8 | + const url = await getLocalTestUrl({ testDir: __dirname }); |
| 9 | + |
| 10 | + const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url); |
| 11 | + |
| 12 | + expect(eventData).toEqual({ |
| 13 | + exception: { |
| 14 | + values: [ |
| 15 | + expect.objectContaining({ |
| 16 | + type: 'Error', |
| 17 | + value: 'test client', |
| 18 | + mechanism: { |
| 19 | + type: 'generic', |
| 20 | + handled: true, |
| 21 | + }, |
| 22 | + stacktrace: { |
| 23 | + frames: expect.any(Array), |
| 24 | + }, |
| 25 | + }), |
| 26 | + ], |
| 27 | + }, |
| 28 | + level: 'error', |
| 29 | + event_id: expect.any(String), |
| 30 | + platform: 'javascript', |
| 31 | + request: { |
| 32 | + url, |
| 33 | + headers: expect.objectContaining({ |
| 34 | + 'User-Agent': expect.any(String), |
| 35 | + }), |
| 36 | + }, |
| 37 | + timestamp: expect.any(Number), |
| 38 | + environment: 'local', |
| 39 | + release: '0.0.1', |
| 40 | + sdk: { |
| 41 | + integrations: ['Breadcrumbs', 'FunctionToString', 'Dedupe', 'HttpContext', 'InboundFilters', 'LinkedErrors'], |
| 42 | + name: 'sentry.javascript.browser', |
| 43 | + version: expect.any(String), |
| 44 | + packages: [{ name: expect.any(String), version: expect.any(String) }], |
| 45 | + }, |
| 46 | + contexts: { trace: { trace_id: expect.any(String), span_id: expect.any(String) } }, |
| 47 | + }); |
| 48 | +}); |
0 commit comments