Skip to content

Commit 84d7334

Browse files
ignored rule import/first for tests, rolled back tests affected by mock order
1 parent 0fc0fc1 commit 84d7334

13 files changed

Lines changed: 56 additions & 39 deletions

packages/core/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ module.exports = {
3838
'@typescript-eslint/no-empty-function': 'off',
3939
'@typescript-eslint/no-explicit-any': 'off',
4040
'@typescript-eslint/unbound-method': 'off',
41+
'import/first': 'off',
4142
},
4243
},
4344
{

packages/core/test/integrations/integrationsexecutionorder.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
import * as mockWrapper from '../mockWrapper';
2+
3+
jest.mock('../../src/js/wrapper', () => mockWrapper);
4+
jest.mock('../../src/js/utils/environment');
5+
16
import { defaultStackParser } from '@sentry/browser';
27
import type { Integration } from '@sentry/core';
38
import { ReactNativeClient } from '../../src/js/client';
49
import { getDefaultIntegrations } from '../../src/js/integrations/default';
510
import type { ReactNativeClientOptions } from '../../src/js/options';
611
import { isHermesEnabled, notWeb } from '../../src/js/utils/environment';
712
import { MOCK_DSN } from '../mockDsn';
8-
import * as mockWrapper from '../mockWrapper';
9-
10-
jest.mock('../../src/js/wrapper', () => mockWrapper);
11-
jest.mock('../../src/js/utils/environment');
1213

1314
describe('Integration execution order', () => {
1415
describe('mobile hermes', () => {

packages/core/test/profiling/integration.test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
import * as mockWrapper from '../mockWrapper';
2+
3+
jest.mock('../../src/js/wrapper', () => mockWrapper);
4+
jest.mock('../../src/js/utils/environment');
5+
jest.mock('../../src/js/profiling/debugid');
6+
17
import type { Envelope, Event, Integration, Profile, Span, ThreadCpuProfile, Transport } from '@sentry/core';
28
import { getClient, spanToJSON } from '@sentry/core';
39
import * as Sentry from '../../src/js';
@@ -7,7 +13,6 @@ import { hermesProfilingIntegration } from '../../src/js/profiling/integration';
713
import type { AndroidProfileEvent } from '../../src/js/profiling/types';
814
import { getDefaultEnvironment, isHermesEnabled, notWeb } from '../../src/js/utils/environment';
915
import { MOCK_DSN } from '../mockDsn';
10-
import * as mockWrapper from '../mockWrapper';
1116
import { envelopeItemPayload, envelopeItems } from '../testutils';
1217
import {
1318
createMockMinimalValidAndroidProfile,
@@ -16,10 +21,6 @@ import {
1621
createMockMinimalValidHermesProfile,
1722
} from './fixtures';
1823

19-
jest.mock('../../src/js/wrapper', () => mockWrapper);
20-
jest.mock('../../src/js/utils/environment');
21-
jest.mock('../../src/js/profiling/debugid');
22-
2324
const SEC_TO_MS = 1e6;
2425

2526
describe('profiling integration', () => {

packages/core/test/scopeSync.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import * as SentryCore from '@sentry/core';
33
import { Scope } from '@sentry/core';
44
import { enableSyncToNative } from '../src/js/scopeSync';
55
import { getDefaultTestClientOptions, TestClient } from './mocks/client';
6-
import { NATIVE } from './mockWrapper';
76

87
jest.mock('../src/js/wrapper', () => jest.requireActual('./mockWrapper'));
98

9+
import { NATIVE } from './mockWrapper';
10+
1011
jest.mock('../src/js/wrapper');
1112

1213
describe('ScopeSync', () => {

packages/core/test/tools/collectModules.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { logger } from '@sentry/core';
22
import { existsSync, readFileSync, rmdirSync, unlinkSync } from 'fs';
33
import { dirname } from 'path';
4-
import ModulesCollector from '../../src/js/tools/ModulesCollector';
54

65
jest.mock('@sentry/core');
76
(logger.enable as jest.Mock).mockImplementation(() => {});
87

8+
import ModulesCollector from '../../src/js/tools/ModulesCollector';
9+
910
describe('collectModules', () => {
1011
test('should collect modules from multiple modules paths', () => {
1112
const modules = ModulesCollector.collect(

packages/core/test/tools/sentryBabelTransformer.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import {
44
SENTRY_BABEL_TRANSFORMER_OPTIONS,
55
SENTRY_DEFAULT_BABEL_TRANSFORMER_PATH,
66
} from '../../src/js/tools/sentryBabelTransformerUtils';
7-
import type { BabelTransformerArgs } from '../../src/js/tools/vendor/metro/metroBabelTransformer';
87

98
process.env[SENTRY_DEFAULT_BABEL_TRANSFORMER_PATH] = require.resolve('./fixtures/mockBabelTransformer.js');
109

10+
import type { BabelTransformerArgs } from '../../src/js/tools/vendor/metro/metroBabelTransformer';
11+
1112
const MockDefaultBabelTransformer: {
1213
transform: jest.Mock;
1314
getCacheKey: jest.Mock;

packages/core/test/tracing/reactnativetracing.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import * as SentryBrowser from '@sentry/browser';
22
import type { Event } from '@sentry/core';
3-
import { reactNativeTracingIntegration } from '../../src/js/tracing/reactnativetracing';
4-
import { isWeb } from '../../src/js/utils/environment';
5-
import type { TestClient } from '../mocks/client';
6-
import { setupTestClient } from '../mocks/client';
73

84
jest.mock('../../src/js/wrapper', () => {
95
return {
@@ -17,6 +13,11 @@ jest.mock('../../src/js/wrapper', () => {
1713
};
1814
});
1915

16+
import { reactNativeTracingIntegration } from '../../src/js/tracing/reactnativetracing';
17+
import { isWeb } from '../../src/js/utils/environment';
18+
import type { TestClient } from '../mocks/client';
19+
import { setupTestClient } from '../mocks/client';
20+
2021
jest.mock('../../src/js/tracing/utils', () => {
2122
const originalUtils = jest.requireActual('../../src/js/tracing/utils');
2223

packages/core/test/tracing/reactnavigation.stalltracking.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
jest.mock('../../src/js/tracing/utils', () => ({
2+
...jest.requireActual('../../src/js/tracing/utils'),
3+
isNearToNow: jest.fn(),
4+
}));
5+
16
import { getCurrentScope, getGlobalScope, getIsolationScope, setCurrentClient, startSpanManual } from '@sentry/core';
27
import { reactNativeTracingIntegration, reactNavigationIntegration } from '../../src/js';
38
import { stallTrackingIntegration } from '../../src/js/tracing/integrations/stalltracking';
@@ -7,11 +12,6 @@ import { getDefaultTestClientOptions, TestClient } from '../mocks/client';
712
import { expectStallMeasurements } from './integrations/stallTracking/stalltrackingutils';
813
import { createMockNavigationAndAttachTo } from './reactnavigationutils';
914

10-
jest.mock('../../src/js/tracing/utils', () => ({
11-
...jest.requireActual('../../src/js/tracing/utils'),
12-
isNearToNow: jest.fn(),
13-
}));
14-
1515
jest.useFakeTimers({ advanceTimers: 1 });
1616

1717
describe('StallTracking with ReactNavigation', () => {

packages/core/test/tracing/reactnavigation.ttid.test.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ import type { Scope, Span, SpanJSON, TransactionEvent, Transport } from '@sentry
22
import { getActiveSpan, spanToJSON, timestampInSeconds } from '@sentry/core';
33
import * as TestRenderer from '@testing-library/react-native'
44
import * as React from 'react';
5+
import * as mockWrapper from '../mockWrapper';
6+
import * as mockedSentryEventEmitter from '../utils/mockedSentryeventemitterfallback';
7+
import * as mockedtimetodisplaynative from './mockedtimetodisplaynative';
8+
9+
jest.mock('../../src/js/wrapper', () => mockWrapper);
10+
jest.mock('../../src/js/utils/environment');
11+
jest.mock('../../src/js/utils/sentryeventemitterfallback', () => mockedSentryEventEmitter);
12+
jest.mock('../../src/js/tracing/timetodisplaynative', () => mockedtimetodisplaynative);
13+
514
import * as Sentry from '../../src/js';
615
import { startSpanManual } from '../../src/js';
716
import { TimeToFullDisplay, TimeToInitialDisplay } from '../../src/js/tracing';
@@ -11,17 +20,10 @@ import { SPAN_THREAD_NAME, SPAN_THREAD_NAME_JAVASCRIPT } from '../../src/js/trac
1120
import { isHermesEnabled, notWeb } from '../../src/js/utils/environment';
1221
import { RN_GLOBAL_OBJ } from '../../src/js/utils/worldwide';
1322
import { MOCK_DSN } from '../mockDsn';
14-
import * as mockWrapper from '../mockWrapper';
1523
import { nowInSeconds, secondInFutureTimestampMs } from '../testutils';
16-
import * as mockedSentryEventEmitter from '../utils/mockedSentryeventemitterfallback';
17-
import * as mockedtimetodisplaynative from './mockedtimetodisplaynative';
1824
import { mockRecordedTimeToDisplay } from './mockedtimetodisplaynative';
1925
import { createMockNavigationAndAttachTo } from './reactnavigationutils';
2026

21-
jest.mock('../../src/js/wrapper', () => mockWrapper);
22-
jest.mock('../../src/js/utils/environment');
23-
jest.mock('../../src/js/utils/sentryeventemitterfallback', () => mockedSentryEventEmitter);
24-
jest.mock('../../src/js/tracing/timetodisplaynative', () => mockedtimetodisplaynative);
2527

2628
const SCOPE_SPAN_FIELD = '_sentrySpan';
2729

packages/core/test/tracing/timetodisplay.test.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
import type { Event, Measurements, Span, SpanJSON} from '@sentry/core';
22
import { getCurrentScope, getGlobalScope, getIsolationScope, logger , setCurrentClient, spanToJSON, startSpanManual } from '@sentry/core';
3+
4+
jest.spyOn(logger, 'warn');
5+
6+
import * as mockWrapper from '../mockWrapper';
7+
8+
jest.mock('../../src/js/wrapper', () => mockWrapper);
9+
10+
import * as mockedtimetodisplaynative from './mockedtimetodisplaynative';
11+
12+
jest.mock('../../src/js/tracing/timetodisplaynative', () => mockedtimetodisplaynative);
13+
314
import * as React from 'react';
415
import * as TestRenderer from 'react-test-renderer';
516
import { timeToDisplayIntegration } from '../../src/js/tracing/integrations/timeToDisplayIntegration';
@@ -9,13 +20,8 @@ import { SPAN_THREAD_NAME , SPAN_THREAD_NAME_JAVASCRIPT } from '../../src/js/tra
920
import { startTimeToFullDisplaySpan, startTimeToInitialDisplaySpan, TimeToFullDisplay, TimeToInitialDisplay } from '../../src/js/tracing/timetodisplay';
1021
import { isTurboModuleEnabled } from '../../src/js/utils/environment';
1122
import { getDefaultTestClientOptions, TestClient } from '../mocks/client';
12-
import * as mockWrapper from '../mockWrapper';
1323
import { nowInSeconds, secondAgoTimestampMs, secondInFutureTimestampMs } from '../testutils';
14-
import * as mockedtimetodisplaynative from './mockedtimetodisplaynative';
1524

16-
jest.spyOn(logger, 'warn');
17-
jest.mock('../../src/js/wrapper', () => mockWrapper);
18-
jest.mock('../../src/js/tracing/timetodisplaynative', () => mockedtimetodisplaynative);
1925
jest.mock('../../src/js/utils/environment', () => ({
2026
isWeb: jest.fn().mockReturnValue(false),
2127
isTurboModuleEnabled: jest.fn().mockReturnValue(false),

0 commit comments

Comments
 (0)