|
1 | 1 | import { expect, test } from '@playwright/test'; |
2 | 2 | import axios, { AxiosError } from 'axios'; |
| 3 | +import { waitForError } from '../event-proxy-server'; |
3 | 4 |
|
4 | 5 | const authToken = process.env.E2E_TEST_AUTH_TOKEN; |
5 | 6 | const sentryTestOrgSlug = process.env.E2E_TEST_SENTRY_ORG_SLUG; |
@@ -37,3 +38,36 @@ test('Sends exception to Sentry', async ({ baseURL }) => { |
37 | 38 | ) |
38 | 39 | .toBe(200); |
39 | 40 | }); |
| 41 | + |
| 42 | +test('Sends correct error event', async ({ baseURL }) => { |
| 43 | + const errorEventPromise = waitForError('node-fastify-app', event => { |
| 44 | + return !event.type; |
| 45 | + }); |
| 46 | + |
| 47 | + await axios.get(`${baseURL}/test-exception`); |
| 48 | + |
| 49 | + const errorEvent = await errorEventPromise; |
| 50 | + |
| 51 | + console.log(JSON.stringify(errorEvent, null, 2)); |
| 52 | + |
| 53 | + expect(errorEvent.exception?.values).toHaveLength(1); |
| 54 | + expect(errorEvent.exception?.values?.[0]?.value).toBe('This is an exception.'); |
| 55 | + |
| 56 | + expect(errorEvent.request).toEqual({}); |
| 57 | + |
| 58 | + expect(errorEvent).toEqual({ |
| 59 | + request: { |
| 60 | + method: 'GET', |
| 61 | + cookies: {}, |
| 62 | + headers: expect.any(Object), |
| 63 | + url: 'http://localhost:3030/test-exception', |
| 64 | + }, |
| 65 | + }); |
| 66 | + |
| 67 | + expect(errorEvent.transaction).toEqual('GET /test-exception'); |
| 68 | + |
| 69 | + expect(errorEvent.contexts?.trace).toEqual({ |
| 70 | + trace_id: expect.any(String), |
| 71 | + span_id: expect.any(String), |
| 72 | + }); |
| 73 | +}); |
0 commit comments