@@ -511,21 +511,7 @@ describe('DocumentLoad Plugin', () => {
511
511
} ) ;
512
512
} ) ;
513
513
514
- describe ( 'when navigation entries types are NOT available then fallback to "performance.timing"' , ( ) => {
515
- let spyEntries : any ;
516
- beforeEach ( ( ) => {
517
- spyEntries = sinon . stub ( window . performance , 'getEntriesByType' ) ;
518
- spyEntries . withArgs ( 'navigation' ) . returns ( [ ] ) ;
519
- spyEntries . withArgs ( 'resource' ) . returns ( [ ] ) ;
520
- Object . defineProperty ( window . performance , 'timing' , {
521
- writable : true ,
522
- value : entriesFallback ,
523
- } ) ;
524
- } ) ;
525
- afterEach ( ( ) => {
526
- spyEntries . restore ( ) ;
527
- } ) ;
528
-
514
+ function shouldExportCorrectSpan ( ) {
529
515
it ( 'should export correct span with events' , done => {
530
516
const spyOnEnd = sinon . spy ( dummyExporter , 'export' ) ;
531
517
plugin . enable ( moduleExports , provider , logger , config ) ;
@@ -557,6 +543,41 @@ describe('DocumentLoad Plugin', () => {
557
543
done ( ) ;
558
544
} ) ;
559
545
} ) ;
546
+ }
547
+
548
+ describe ( 'when navigation entries types are NOT available then fallback to "performance.timing"' , ( ) => {
549
+ let spyEntries : any ;
550
+ beforeEach ( ( ) => {
551
+ spyEntries = sinon . stub ( window . performance , 'getEntriesByType' ) ;
552
+ spyEntries . withArgs ( 'navigation' ) . returns ( [ ] ) ;
553
+ spyEntries . withArgs ( 'resource' ) . returns ( [ ] ) ;
554
+
555
+ Object . defineProperty ( window . performance , 'timing' , {
556
+ writable : true ,
557
+ value : entriesFallback ,
558
+ } ) ;
559
+ } ) ;
560
+ afterEach ( ( ) => {
561
+ spyEntries . restore ( ) ;
562
+ } ) ;
563
+
564
+ shouldExportCorrectSpan ( ) ;
565
+ } ) ;
566
+
567
+ describe ( 'when getEntriesByType is not defined then fallback to "performance.timing"' , ( ) => {
568
+ beforeEach ( ( ) => {
569
+ Object . defineProperty ( window . performance , 'getEntriesByType' , {
570
+ writable : true ,
571
+ value : undefined ,
572
+ } ) ;
573
+
574
+ Object . defineProperty ( window . performance , 'timing' , {
575
+ writable : true ,
576
+ value : entriesFallback ,
577
+ } ) ;
578
+ } ) ;
579
+
580
+ shouldExportCorrectSpan ( ) ;
560
581
} ) ;
561
582
562
583
describe ( 'when navigation entries types and "performance.timing" are NOT available' , ( ) => {
0 commit comments