File tree 1 file changed +9
-0
lines changed
packages/core/test/tracing/integrations
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,8 @@ import { NATIVE } from '../../../src/js/wrapper';
33
33
import { getDefaultTestClientOptions , TestClient } from '../../mocks/client' ;
34
34
import { mockFunction } from '../../testutils' ;
35
35
36
+ let dateNowSpy : jest . SpyInstance ;
37
+
36
38
jest . mock ( '../../../src/js/wrapper' , ( ) => {
37
39
return {
38
40
NATIVE : {
@@ -1057,6 +1059,9 @@ function mockTooOldAppStart() {
1057
1059
function mockReactNativeBundleExecutionStartTimestamp ( ) {
1058
1060
RN_GLOBAL_OBJ . nativePerformanceNow = ( ) => 100 ; // monotonic clock like `performance.now()`
1059
1061
RN_GLOBAL_OBJ . __BUNDLE_START_TIME__ = 50 ; // 50ms after time origin
1062
+
1063
+ const currentTimeMilliseconds = Date . now ( ) ;
1064
+ dateNowSpy = jest . spyOn ( Date , 'now' ) . mockImplementation ( ( ) => currentTimeMilliseconds ) ;
1060
1065
}
1061
1066
1062
1067
/**
@@ -1065,6 +1070,10 @@ function mockReactNativeBundleExecutionStartTimestamp() {
1065
1070
function clearReactNativeBundleExecutionStartTimestamp ( ) {
1066
1071
delete RN_GLOBAL_OBJ . nativePerformanceNow ;
1067
1072
delete RN_GLOBAL_OBJ . __BUNDLE_START_TIME__ ;
1073
+
1074
+ if ( dateNowSpy ) {
1075
+ dateNowSpy . mockRestore ( ) ;
1076
+ }
1068
1077
}
1069
1078
1070
1079
function set__DEV__ ( value : boolean ) {
You can’t perform that action at this time.
0 commit comments