File tree Expand file tree Collapse file tree
dev-packages/browser-integration-tests/suites/integrations/viewHierarchy Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import * as Sentry from '@sentry/browser' ;
2+ import { viewHierarchyIntegration } from '@sentry/browser' ;
3+
4+ window . Sentry = Sentry ;
5+
6+ Sentry . init ( {
7+ dsn : 'https://public@dsn.ingest.sentry.io/1337' ,
8+ integrations : [ viewHierarchyIntegration ( ) ] ,
9+ } ) ;
Original file line number Diff line number Diff line change 1+ throw new Error ( 'Some error' ) ;
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+ </ head >
7+ < body >
8+ < h1 > Some title</ h1 >
9+ < p > Some text</ p >
10+ </ body >
11+ </ html >
Original file line number Diff line number Diff line change 1+ import { expect } from '@playwright/test' ;
2+ import type { ViewHierarchyData } from '@sentry/core' ;
3+ import { sentryTest } from '../../../utils/fixtures' ;
4+ import { getMultipleSentryEnvelopeRequests , envelopeParser } from '../../../utils/helpers' ;
5+
6+ sentryTest ( 'Captures view hierarchy as attachment' , async ( { getLocalTestUrl, page } ) => {
7+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
8+
9+ const [ , events ] = await Promise . all ( [
10+ page . goto ( url ) ,
11+ getMultipleSentryEnvelopeRequests < ViewHierarchyData > (
12+ page ,
13+ 1 ,
14+ { } ,
15+ req => envelopeParser ( req ) ?. [ 4 ] as ViewHierarchyData ,
16+ ) ,
17+ ] ) ;
18+
19+ expect ( events ) . toHaveLength ( 1 ) ;
20+ const event : ViewHierarchyData = events [ 0 ] ;
21+
22+ expect ( event . rendering_system ) . toBe ( 'DOM' ) ;
23+ expect ( event . positioning ) . toBe ( 'absolute' ) ;
24+ expect ( event . windows ) . toHaveLength ( 2 ) ;
25+ expect ( event . windows [ 0 ] . type ) . toBe ( 'h1' ) ;
26+ expect ( event . windows [ 0 ] . visible ) . toBe ( true ) ;
27+ expect ( event . windows [ 0 ] . alpha ) . toBe ( 1 ) ;
28+ expect ( event . windows [ 0 ] . children ) . toHaveLength ( 0 ) ;
29+
30+ expect ( event . windows [ 1 ] . type ) . toBe ( 'p' ) ;
31+ expect ( event . windows [ 1 ] . visible ) . toBe ( true ) ;
32+ expect ( event . windows [ 1 ] . alpha ) . toBe ( 1 ) ;
33+ expect ( event . windows [ 1 ] . children ) . toHaveLength ( 0 ) ;
34+ } ) ;
You can’t perform that action at this time.
0 commit comments