|
| 1 | +import { expect } from '@playwright/test'; |
| 2 | +import { sentryTest } from '../../../../utils/fixtures'; |
| 3 | +import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers'; |
| 4 | + |
| 5 | +sentryTest('captures custom AggregateErrors', async ({ getLocalTestUrl, page }) => { |
| 6 | + const url = await getLocalTestUrl({ testDir: __dirname }); |
| 7 | + const req = await waitForErrorRequestOnUrl(page, url); |
| 8 | + const eventData = envelopeRequestParser(req); |
| 9 | + |
| 10 | + expect(eventData.exception?.values).toHaveLength(5); // CustomAggregateError + 3 embedded errors + 1 aggregate cause |
| 11 | + |
| 12 | + // Verify the embedded errors come first |
| 13 | + expect(eventData.exception?.values).toEqual([ |
| 14 | + { |
| 15 | + mechanism: { exception_id: 4, handled: true, parent_id: 0, source: 'errors[1]', type: 'chained' }, |
| 16 | + stacktrace: { |
| 17 | + frames: [ |
| 18 | + { colno: 12, filename: 'http://sentry-test.io/subject.bundle.js', function: '?', in_app: true, lineno: 14 }, |
| 19 | + { colno: 5, filename: 'http://sentry-test.io/subject.bundle.js', function: '?', in_app: true, lineno: 10 }, |
| 20 | + ], |
| 21 | + }, |
| 22 | + type: 'Error', |
| 23 | + value: 'error 2', |
| 24 | + }, |
| 25 | + { |
| 26 | + mechanism: { exception_id: 3, handled: true, parent_id: 2, source: 'cause', type: 'chained' }, |
| 27 | + stacktrace: { |
| 28 | + frames: [ |
| 29 | + { colno: 12, filename: 'http://sentry-test.io/subject.bundle.js', function: '?', in_app: true, lineno: 14 }, |
| 30 | + { colno: 10, filename: 'http://sentry-test.io/subject.bundle.js', function: '?', in_app: true, lineno: 9 }, |
| 31 | + ], |
| 32 | + }, |
| 33 | + type: 'Error', |
| 34 | + value: 'error 1 cause', |
| 35 | + }, |
| 36 | + { |
| 37 | + mechanism: { exception_id: 2, handled: true, parent_id: 0, source: 'errors[0]', type: 'chained' }, |
| 38 | + stacktrace: { |
| 39 | + frames: [ |
| 40 | + { colno: 12, filename: 'http://sentry-test.io/subject.bundle.js', function: '?', in_app: true, lineno: 14 }, |
| 41 | + { colno: 50, filename: 'http://sentry-test.io/subject.bundle.js', function: '?', in_app: true, lineno: 8 }, |
| 42 | + ], |
| 43 | + }, |
| 44 | + type: 'Error', |
| 45 | + value: 'error 1', |
| 46 | + }, |
| 47 | + { |
| 48 | + mechanism: { exception_id: 1, handled: true, parent_id: 0, source: 'cause', type: 'chained' }, |
| 49 | + stacktrace: { |
| 50 | + frames: [ |
| 51 | + { colno: 12, filename: 'http://sentry-test.io/subject.bundle.js', function: '?', in_app: true, lineno: 14 }, |
| 52 | + { colno: 10, filename: 'http://sentry-test.io/subject.bundle.js', function: '?', in_app: true, lineno: 11 }, |
| 53 | + ], |
| 54 | + }, |
| 55 | + type: 'Error', |
| 56 | + value: 'aggregate cause', |
| 57 | + }, |
| 58 | + { |
| 59 | + mechanism: { exception_id: 0, handled: true, type: 'generic', is_exception_group: true }, |
| 60 | + stacktrace: { |
| 61 | + frames: [ |
| 62 | + { colno: 12, filename: 'http://sentry-test.io/subject.bundle.js', function: '?', in_app: true, lineno: 14 }, |
| 63 | + { colno: 24, filename: 'http://sentry-test.io/subject.bundle.js', function: '?', in_app: true, lineno: 8 }, |
| 64 | + ], |
| 65 | + }, |
| 66 | + type: 'CustomAggregateError', |
| 67 | + value: 'custom aggregate error', |
| 68 | + }, |
| 69 | + ]); |
| 70 | +}); |
0 commit comments