|
1 | 1 | import * as mockedtimetodisplaynative from './mockedtimetodisplaynative';
|
2 | 2 | jest.mock('../../src/js/tracing/timetodisplaynative', () => mockedtimetodisplaynative);
|
| 3 | +import { isTurboModuleEnabled } from '../../src/js/utils/environment'; |
| 4 | +jest.mock('../../src/js/utils/environment', () => ({ |
| 5 | + isTurboModuleEnabled: jest.fn().mockReturnValue(false), |
| 6 | +})); |
| 7 | +jest.spyOn(logger, 'warn'); |
3 | 8 |
|
4 | 9 | import type { Span as SpanClass} from '@sentry/core';
|
5 | 10 | import { getActiveSpan, getCurrentScope, getGlobalScope, getIsolationScope, setCurrentClient, spanToJSON, startSpanManual} from '@sentry/core';
|
6 | 11 | import type { Event, Measurements, Span, SpanJSON} from '@sentry/types';
|
| 12 | +import { logger } from '@sentry/utils'; |
7 | 13 | import React from "react";
|
8 | 14 | import TestRenderer from 'react-test-renderer';
|
9 | 15 |
|
@@ -373,6 +379,26 @@ describe('TimeToDisplay', () => {
|
373 | 379 | expect(spanToJSON(initialDisplaySpan!).timestamp).toEqual(initialDisplayEndTimestampMs / 1_000);
|
374 | 380 | expect(spanToJSON(fullDisplaySpan!).timestamp).toEqual(fullDisplayEndTimestampMs / 1_000);
|
375 | 381 | });
|
| 382 | + |
| 383 | + test('should not log a warning if native component exists and not in new architecture', async () => { |
| 384 | + |
| 385 | + (isTurboModuleEnabled as jest.Mock).mockReturnValue(false); |
| 386 | + |
| 387 | + TestRenderer.create(<TimeToInitialDisplay record={true} />); |
| 388 | + await jest.runOnlyPendingTimersAsync(); // Flush setTimeout. |
| 389 | + |
| 390 | + expect(logger.warn).not.toHaveBeenCalled(); |
| 391 | + }); |
| 392 | + |
| 393 | + test('should log a warning if in new architecture', async () => { |
| 394 | + |
| 395 | + (isTurboModuleEnabled as jest.Mock).mockReturnValue(true); |
| 396 | + TestRenderer.create(<TimeToInitialDisplay record={true} />); |
| 397 | + await jest.runOnlyPendingTimersAsync(); // Flush setTimeout. |
| 398 | + |
| 399 | + expect(logger.warn).toHaveBeenCalledWith( |
| 400 | + 'TimeToInitialDisplay and TimeToFullDisplay are not supported on the web, Expo Go and New Architecture. Run native build or report an issue at https://github.com/getsentry/sentry-react-native'); |
| 401 | + }); |
376 | 402 | });
|
377 | 403 |
|
378 | 404 | function getInitialDisplaySpan(span?: Span) {
|
|
0 commit comments