@@ -4,6 +4,12 @@ import { waitForError } from '@sentry-internal/test-utils';
44const tunnelRouteMode =
55 process . env . E2E_TEST_TUNNEL_ROUTE_MODE ??
66 ( process . env . E2E_TEST_CUSTOM_TUNNEL_ROUTE === '1' ? 'custom' : 'off' ) ;
7+ const expectedTunnelPathMatcher =
8+ tunnelRouteMode === 'static'
9+ ? '/monitor'
10+ : tunnelRouteMode === 'custom'
11+ ? '/custom-monitor'
12+ : / ^ \/ [ a - z 0 - 9 ] { 8 } $ / ;
713
814test . skip ( tunnelRouteMode === 'off' , 'Tunnel assertions only run in the tunnel-route variants' ) ;
915
@@ -20,7 +26,13 @@ test('Sends client-side errors through the configured tunnel route', async ({ pa
2026 const managedTunnelResponsePromise = page . waitForResponse ( response => {
2127 const responseUrl = new URL ( response . url ( ) ) ;
2228
23- return responseUrl . origin === pageOrigin && response . request ( ) . method ( ) === 'POST' ;
29+ return (
30+ responseUrl . origin === pageOrigin &&
31+ response . request ( ) . method ( ) === 'POST' &&
32+ ( typeof expectedTunnelPathMatcher === 'string'
33+ ? responseUrl . pathname === expectedTunnelPathMatcher
34+ : expectedTunnelPathMatcher . test ( responseUrl . pathname ) )
35+ ) ;
2436 } ) ;
2537
2638 await page . locator ( 'button' ) . filter ( { hasText : 'Break the client' } ) . click ( ) ;
@@ -32,12 +44,10 @@ test('Sends client-side errors through the configured tunnel route', async ({ pa
3244 expect ( managedTunnelResponse . status ( ) ) . toBe ( 200 ) ;
3345 expect ( managedTunnelUrl . origin ) . toBe ( pageOrigin ) ;
3446
35- if ( tunnelRouteMode === 'static' ) {
36- expect ( managedTunnelUrl . pathname ) . toBe ( '/monitor' ) ;
37- } else if ( tunnelRouteMode === 'custom' ) {
38- expect ( managedTunnelUrl . pathname ) . toBe ( '/custom-monitor' ) ;
47+ if ( typeof expectedTunnelPathMatcher === 'string' ) {
48+ expect ( managedTunnelUrl . pathname ) . toBe ( expectedTunnelPathMatcher ) ;
3949 } else {
40- expect ( managedTunnelUrl . pathname ) . toMatch ( / ^ \/ [ a - z 0 - 9 ] { 8 } $ / ) ;
50+ expect ( managedTunnelUrl . pathname ) . toMatch ( expectedTunnelPathMatcher ) ;
4151 expect ( managedTunnelUrl . pathname ) . not . toBe ( '/monitor' ) ;
4252 }
4353
0 commit comments