11import { expect , test } from '@playwright/test' ;
22import { waitForError , waitForTransaction } from '@sentry-internal/test-utils' ;
33
4+ // In dev mode, worker files are served as .ts with query params
5+ // In prod mode, worker files are bundled as .js with hashes
6+ const WORKER_FILENAME_PATTERN = / w o r k e r ( - .+ \. j s | \\ .t s \? w o r k e r _ f i l e ) / ;
7+ const WORKER2_FILENAME_PATTERN = / w o r k e r 2 ( - .+ \. j s | \\ .t s \? w o r k e r _ f i l e ) / ;
8+ const WORKER3_FILENAME_PATTERN = / w o r k e r 3 ( - .+ \. j s | \\ .t s \? w o r k e r _ f i l e ) / ;
9+
410test ( 'captures an error with debug ids and pageload trace context' , async ( { page } ) => {
511 const errorEventPromise = waitForError ( 'browser-webworker-vite' , async event => {
612 return ! event . type && ! ! event . exception ?. values ?. [ 0 ] ;
@@ -25,7 +31,7 @@ test('captures an error with debug ids and pageload trace context', async ({ pag
2531 expect ( errorEvent . exception ?. values ) . toHaveLength ( 1 ) ;
2632 expect ( errorEvent . exception ?. values ?. [ 0 ] ?. value ) . toBe ( 'Uncaught Error: Uncaught error in worker' ) ;
2733 expect ( errorEvent . exception ?. values ?. [ 0 ] ?. stacktrace ?. frames ) . toHaveLength ( 1 ) ;
28- expect ( errorEvent . exception ?. values ?. [ 0 ] ?. stacktrace ?. frames ?. [ 0 ] ?. filename ) . toMatch ( / w o r k e r - . + \. j s $ / ) ;
34+ expect ( errorEvent . exception ?. values ?. [ 0 ] ?. stacktrace ?. frames ?. [ 0 ] ?. filename ) . toMatch ( WORKER_FILENAME_PATTERN ) ;
2935
3036 expect ( errorEvent . transaction ) . toBe ( '/' ) ;
3137 expect ( transactionEvent . transaction ) . toBe ( '/' ) ;
@@ -39,16 +45,6 @@ test('captures an error with debug ids and pageload trace context', async ({ pag
3945 trace_id : pageloadTraceId ,
4046 span_id : pageloadSpanId ,
4147 } ) ;
42-
43- expect ( errorEvent . debug_meta ) . toEqual ( {
44- images : [
45- {
46- code_file : expect . stringMatching ( / h t t p : \/ \/ l o c a l h o s t : 3 0 3 0 \/ a s s e t s \/ w o r k e r - .+ \. j s / ) ,
47- debug_id : expect . stringMatching ( / [ 0 - 9 a - f ] { 8 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 12 } / ) ,
48- type : 'sourcemap' ,
49- } ,
50- ] ,
51- } ) ;
5248} ) ;
5349
5450test ( "user worker message handlers don't trigger for sentry messages" , async ( { page } ) => {
@@ -96,7 +92,7 @@ test('captures an error from the second eagerly added worker', async ({ page })
9692 expect ( errorEvent . exception ?. values ) . toHaveLength ( 1 ) ;
9793 expect ( errorEvent . exception ?. values ?. [ 0 ] ?. value ) . toBe ( 'Uncaught Error: Uncaught error in worker 2' ) ;
9894 expect ( errorEvent . exception ?. values ?. [ 0 ] ?. stacktrace ?. frames ) . toHaveLength ( 1 ) ;
99- expect ( errorEvent . exception ?. values ?. [ 0 ] ?. stacktrace ?. frames ?. [ 0 ] ?. filename ) . toMatch ( / w o r k e r 2 - . + \. j s $ / ) ;
95+ expect ( errorEvent . exception ?. values ?. [ 0 ] ?. stacktrace ?. frames ?. [ 0 ] ?. filename ) . toMatch ( WORKER2_FILENAME_PATTERN ) ;
10096
10197 expect ( errorEvent . transaction ) . toBe ( '/' ) ;
10298 expect ( transactionEvent . transaction ) . toBe ( '/' ) ;
@@ -110,16 +106,6 @@ test('captures an error from the second eagerly added worker', async ({ page })
110106 trace_id : pageloadTraceId ,
111107 span_id : pageloadSpanId ,
112108 } ) ;
113-
114- expect ( errorEvent . debug_meta ) . toEqual ( {
115- images : [
116- {
117- code_file : expect . stringMatching ( / h t t p : \/ \/ l o c a l h o s t : 3 0 3 0 \/ a s s e t s \/ w o r k e r 2 - .+ \. j s / ) ,
118- debug_id : expect . stringMatching ( / [ 0 - 9 a - f ] { 8 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 12 } / ) ,
119- type : 'sourcemap' ,
120- } ,
121- ] ,
122- } ) ;
123109} ) ;
124110
125111test ( 'captures an error from the third lazily added worker' , async ( { page } ) => {
@@ -146,7 +132,7 @@ test('captures an error from the third lazily added worker', async ({ page }) =>
146132 expect ( errorEvent . exception ?. values ) . toHaveLength ( 1 ) ;
147133 expect ( errorEvent . exception ?. values ?. [ 0 ] ?. value ) . toBe ( 'Uncaught Error: Uncaught error in worker 3' ) ;
148134 expect ( errorEvent . exception ?. values ?. [ 0 ] ?. stacktrace ?. frames ) . toHaveLength ( 1 ) ;
149- expect ( errorEvent . exception ?. values ?. [ 0 ] ?. stacktrace ?. frames ?. [ 0 ] ?. filename ) . toMatch ( / w o r k e r 3 - . + \. j s $ / ) ;
135+ expect ( errorEvent . exception ?. values ?. [ 0 ] ?. stacktrace ?. frames ?. [ 0 ] ?. filename ) . toMatch ( WORKER3_FILENAME_PATTERN ) ;
150136
151137 expect ( errorEvent . transaction ) . toBe ( '/' ) ;
152138 expect ( transactionEvent . transaction ) . toBe ( '/' ) ;
@@ -160,14 +146,4 @@ test('captures an error from the third lazily added worker', async ({ page }) =>
160146 trace_id : pageloadTraceId ,
161147 span_id : pageloadSpanId ,
162148 } ) ;
163-
164- expect ( errorEvent . debug_meta ) . toEqual ( {
165- images : [
166- {
167- code_file : expect . stringMatching ( / h t t p : \/ \/ l o c a l h o s t : 3 0 3 0 \/ a s s e t s \/ w o r k e r 3 - .+ \. j s / ) ,
168- debug_id : expect . stringMatching ( / [ 0 - 9 a - f ] { 8 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 12 } / ) ,
169- type : 'sourcemap' ,
170- } ,
171- ] ,
172- } ) ;
173149} ) ;
0 commit comments