File tree Expand file tree Collapse file tree 8 files changed +88
-0
lines changed
packages/integration-tests/suites/public-api/captureException Expand file tree Collapse file tree 8 files changed +88
-0
lines changed Original file line number Diff line number Diff line change 1+ Sentry . captureException ( { } ) ;
Original file line number Diff line number Diff line change 1+ import { expect } from '@playwright/test' ;
2+
3+ import { sentryTest } from '../../../../utils/fixtures' ;
4+ import { getSentryRequest } from '../../../../utils/helpers' ;
5+
6+ sentryTest ( 'should capture an empty object' , async ( { getLocalTestPath, page } ) => {
7+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
8+
9+ const eventData = await getSentryRequest ( page , url ) ;
10+
11+ expect ( eventData . exception ?. values ) . toHaveLength ( 1 ) ;
12+ expect ( eventData . exception ?. values ?. [ 0 ] ) . toMatchObject ( {
13+ type : 'Error' ,
14+ value : 'Non-Error exception captured with keys: [object has no keys]' ,
15+ mechanism : {
16+ type : 'generic' ,
17+ handled : true ,
18+ } ,
19+ } ) ;
20+ } ) ;
Original file line number Diff line number Diff line change 1+ import * as Sentry from '@sentry/browser' ;
2+
3+ window . Sentry = Sentry ;
4+
5+ Sentry . init ( {
6+ dsn : 'https://public@dsn.ingest.sentry.io/1337' ,
7+ } ) ;
Original file line number Diff line number Diff line change 1+ try {
2+ throw Error ( 'test_simple_error' ) ;
3+ } catch ( err ) {
4+ Sentry . captureException ( err ) ;
5+ }
Original file line number Diff line number Diff line change 1+ import { expect } from '@playwright/test' ;
2+
3+ import { sentryTest } from '../../../../utils/fixtures' ;
4+ import { getSentryRequest } from '../../../../utils/helpers' ;
5+
6+ sentryTest ( 'should capture a simple error with message' , async ( { getLocalTestPath, page } ) => {
7+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
8+
9+ const eventData = await getSentryRequest ( page , url ) ;
10+
11+ expect ( eventData . exception ?. values ) . toHaveLength ( 1 ) ;
12+ expect ( eventData . exception ?. values ?. [ 0 ] ) . toMatchObject ( {
13+ type : 'Error' ,
14+ value : 'test_simple_error' ,
15+ mechanism : {
16+ type : 'generic' ,
17+ handled : true ,
18+ } ,
19+ stacktrace : {
20+ frames : expect . any ( Array ) ,
21+ } ,
22+ } ) ;
23+ } ) ;
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ <html >
3+ <head >
4+ <meta charset =" utf-8" />
5+ <title ></title >
6+ <script src =" {{ htmlWebpackPlugin.options.initialization }} " ></script >
7+ </head >
8+ <body >
9+ <script src =" {{ htmlWebpackPlugin.options.subject }} " ></script >
10+ </body >
11+ </html >
Original file line number Diff line number Diff line change 1+ Sentry . captureException ( ) ;
Original file line number Diff line number Diff line change 1+ import { expect } from '@playwright/test' ;
2+
3+ import { sentryTest } from '../../../../utils/fixtures' ;
4+ import { getSentryRequest } from '../../../../utils/helpers' ;
5+
6+ sentryTest ( 'should capture an undefined error when no arguments are provided' , async ( { getLocalTestPath, page } ) => {
7+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
8+
9+ const eventData = await getSentryRequest ( page , url ) ;
10+
11+ expect ( eventData . exception ?. values ) . toHaveLength ( 1 ) ;
12+ expect ( eventData . exception ?. values ?. [ 0 ] ) . toMatchObject ( {
13+ type : 'Error' ,
14+ value : 'undefined' ,
15+ mechanism : {
16+ type : 'generic' ,
17+ handled : true ,
18+ } ,
19+ } ) ;
20+ } ) ;
You can’t perform that action at this time.
0 commit comments