File tree Expand file tree Collapse file tree 4 files changed +50
-5
lines changed
dev-packages/e2e-tests/test-applications/default-browser Expand file tree Collapse file tree 4 files changed +50
-5
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,12 @@ webpack(
17
17
minimize : true ,
18
18
minimizer : [ new TerserPlugin ( ) ] ,
19
19
} ,
20
- plugins : [ new webpack . EnvironmentPlugin ( [ 'E2E_TEST_DSN' ] ) , new HtmlWebpackPlugin ( ) ] ,
20
+ plugins : [
21
+ new webpack . EnvironmentPlugin ( [ 'E2E_TEST_DSN' ] ) ,
22
+ new HtmlWebpackPlugin ( {
23
+ template : path . join ( __dirname , 'public/index.html' ) ,
24
+ } ) ,
25
+ ] ,
21
26
mode : 'production' ,
22
27
} ,
23
28
( err , stats ) => {
Original file line number Diff line number Diff line change
1
+ <!doctype html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 " />
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6
+ < title > Default Browser App</ title >
7
+ </ head >
8
+ < body >
9
+ < div id ="app "> </ div >
10
+
11
+ < input type ="button " value ="Capture Exception " id ="exception-button " />
12
+
13
+ <!-- The script tags for the bundled JavaScript files will be injected here by HtmlWebpackPlugin in build.mjs-->
14
+ </ body >
15
+ </ html >
Original file line number Diff line number Diff line change @@ -7,6 +7,6 @@ Sentry.init({
7
7
integrations : [ Sentry . browserTracingIntegration ( ) ] ,
8
8
} ) ;
9
9
10
- setTimeout ( ( ) => {
10
+ document . getElementById ( 'exception-button' ) . addEventListener ( 'click' , ( ) => {
11
11
throw new Error ( 'I am an error!' ) ;
12
- } , 2000 ) ;
12
+ } ) ;
Original file line number Diff line number Diff line change 1
1
import { expect , test } from '@playwright/test' ;
2
+ import { waitForError } from '@sentry-internal/test-utils' ;
2
3
3
- test ( 'testing' , ( ) => {
4
- expect ( true ) . toBe ( true ) ;
4
+ test ( 'Should send correct error event' , async ( { page } ) => {
5
+ const errorEventPromise = waitForError ( 'default-browser' , event => {
6
+ return ! event . type && event . exception ?. values ?. [ 0 ] ?. value === 'I am an error!' ;
7
+ } ) ;
8
+
9
+ await page . goto ( '/' ) ;
10
+
11
+ const exceptionButton = page . locator ( 'id=exception-button' ) ;
12
+ await exceptionButton . click ( ) ;
13
+
14
+ const errorEvent = await errorEventPromise ;
15
+
16
+ expect ( errorEvent . exception ?. values ) . toHaveLength ( 1 ) ;
17
+ expect ( errorEvent . exception ?. values ?. [ 0 ] ?. value ) . toBe ( 'I am an error!' ) ;
18
+
19
+ expect ( errorEvent . transaction ) . toBe ( '/' ) ;
20
+
21
+ expect ( errorEvent . request ) . toEqual ( {
22
+ url : 'http://localhost:3030/' ,
23
+ headers : expect . any ( Object ) ,
24
+ } ) ;
25
+
26
+ expect ( errorEvent . contexts ?. trace ) . toEqual ( {
27
+ trace_id : expect . any ( String ) ,
28
+ span_id : expect . any ( String ) ,
29
+ } ) ;
5
30
} ) ;
You can’t perform that action at this time.
0 commit comments