File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed
packages/remix/test/integration Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Throw error on click
2
+ export default function ClickError ( ) {
3
+ return (
4
+ < div >
5
+ < button
6
+ onClick = { ( ) => {
7
+ throw new Error ( 'ClickError' ) ;
8
+ } }
9
+ id = "click-error"
10
+ >
11
+ Throw error on click
12
+ </ button >
13
+ </ div >
14
+ ) ;
15
+ }
Original file line number Diff line number Diff line change
1
+ import { expect , test } from '@playwright/test' ;
2
+ import { Event } from '@sentry/types' ;
3
+ import { getMultipleSentryEnvelopeRequests } from './utils/helpers' ;
4
+
5
+ const useV2 = process . env . REMIX_VERSION === '2' ;
6
+
7
+ test ( 'should report a manually captured message on click with the correct stacktrace.' , async ( { page } ) => {
8
+ if ( ! useV2 ) {
9
+ test . skip ( ) ;
10
+ return ;
11
+ }
12
+
13
+ await page . goto ( '/click-error' ) ;
14
+
15
+ const promise = getMultipleSentryEnvelopeRequests < Event > ( page , 2 ) ;
16
+ await page . click ( '#click-error' ) ;
17
+
18
+ const envelopes = await promise ;
19
+
20
+ const [ _ , errorEnvelope ] = envelopes ;
21
+
22
+ expect ( errorEnvelope . level ) . toBe ( 'error' ) ;
23
+ expect ( errorEnvelope . sdk ?. name ) . toBe ( 'sentry.javascript.remix' ) ;
24
+
25
+ expect ( errorEnvelope . exception ?. values ) . toMatchObject ( [
26
+ {
27
+ type : 'Error' ,
28
+ value : 'ClickError' ,
29
+ stacktrace : { frames : expect . any ( Array ) } ,
30
+ mechanism : { type : 'instrument' , handled : false } ,
31
+ } ,
32
+ ] ) ;
33
+
34
+ // Check the last frame of the stacktrace
35
+ const stacktrace = errorEnvelope . exception ?. values [ 0 ] ?. stacktrace ?. frames ;
36
+
37
+ expect ( stacktrace ?. [ stacktrace . length - 1 ] . function ) . toBe ( 'onClick' ) ;
38
+ } ) ;
You can’t perform that action at this time.
0 commit comments