1
1
import { expect , test } from '@playwright/test' ;
2
- import axios , { AxiosError } from 'axios' ;
3
2
4
3
const authToken = process . env . E2E_TEST_AUTH_TOKEN ;
5
4
const sentryTestOrgSlug = process . env . E2E_TEST_SENTRY_ORG_SLUG ;
@@ -20,24 +19,12 @@ test('Sends a client-side exception to Sentry', async ({ page }) => {
20
19
await expect
21
20
. poll (
22
21
async ( ) => {
23
- try {
24
- const response = await axios . get (
25
- `https://sentry.io/api/0/projects/${ sentryTestOrgSlug } /${ sentryTestProject } /events/${ exceptionEventId } /` ,
26
- { headers : { Authorization : `Bearer ${ authToken } ` } } ,
27
- ) ;
28
-
29
- return response . status ;
30
- } catch ( e ) {
31
- if ( e instanceof AxiosError && e . response ) {
32
- if ( e . response . status !== 404 ) {
33
- throw e ;
34
- } else {
35
- return e . response . status ;
36
- }
37
- } else {
38
- throw e ;
39
- }
40
- }
22
+ const response = await fetch (
23
+ `https://sentry.io/api/0/projects/${ sentryTestOrgSlug } /${ sentryTestProject } /events/${ exceptionEventId } /` ,
24
+ { headers : { Authorization : `Bearer ${ authToken } ` } } ,
25
+ ) ;
26
+
27
+ return response . status ;
41
28
} ,
42
29
{
43
30
timeout : EVENT_POLLING_TIMEOUT ,
@@ -71,28 +58,19 @@ test('Sends a pageload transaction to Sentry', async ({ page }) => {
71
58
await expect
72
59
. poll (
73
60
async ( ) => {
74
- try {
75
- const response = await axios . get (
76
- `https://sentry.io/api/0/projects/${ sentryTestOrgSlug } /${ sentryTestProject } /events/${ transactionEventId } /` ,
77
- { headers : { Authorization : `Bearer ${ authToken } ` } } ,
78
- ) ;
79
-
80
- if ( response . data . contexts . trace . op === 'pageload' ) {
61
+ const response = await fetch (
62
+ `https://sentry.io/api/0/projects/${ sentryTestOrgSlug } /${ sentryTestProject } /events/${ transactionEventId } /` ,
63
+ { headers : { Authorization : `Bearer ${ authToken } ` } } ,
64
+ ) ;
65
+
66
+ if ( response . ok ) {
67
+ const data = await response . json ( ) ;
68
+ if ( data . contexts . trace . op === 'pageload' ) {
81
69
hadPageLoadTransaction = true ;
82
70
}
83
-
84
- return response . status ;
85
- } catch ( e ) {
86
- if ( e instanceof AxiosError && e . response ) {
87
- if ( e . response . status !== 404 ) {
88
- throw e ;
89
- } else {
90
- return e . response . status ;
91
- }
92
- } else {
93
- throw e ;
94
- }
95
71
}
72
+
73
+ return response . status ;
96
74
} ,
97
75
{
98
76
timeout : EVENT_POLLING_TIMEOUT ,
@@ -136,28 +114,19 @@ test('Sends a navigation transaction to Sentry', async ({ page }) => {
136
114
await expect
137
115
. poll (
138
116
async ( ) => {
139
- try {
140
- const response = await axios . get (
141
- `https://sentry.io/api/0/projects/${ sentryTestOrgSlug } /${ sentryTestProject } /events/${ transactionEventId } /` ,
142
- { headers : { Authorization : `Bearer ${ authToken } ` } } ,
143
- ) ;
144
-
145
- if ( response . data . contexts . trace . op === 'navigation' ) {
117
+ const response = await fetch (
118
+ `https://sentry.io/api/0/projects/${ sentryTestOrgSlug } /${ sentryTestProject } /events/${ transactionEventId } /` ,
119
+ { headers : { Authorization : `Bearer ${ authToken } ` } } ,
120
+ ) ;
121
+
122
+ if ( response . ok ) {
123
+ const data = await response . json ( ) ;
124
+ if ( data . contexts . trace . op === 'navigation' ) {
146
125
hadPageNavigationTransaction = true ;
147
126
}
148
-
149
- return response . status ;
150
- } catch ( e ) {
151
- if ( e instanceof AxiosError && e . response ) {
152
- if ( e . response . status !== 404 ) {
153
- throw e ;
154
- } else {
155
- return e . response . status ;
156
- }
157
- } else {
158
- throw e ;
159
- }
160
127
}
128
+
129
+ return response . status ;
161
130
} ,
162
131
{
163
132
timeout : EVENT_POLLING_TIMEOUT ,
0 commit comments