Skip to content

Commit 9ead587

Browse files
committed
test(replay): Stop using @test imports
For symmetry with the other packages, just use proper import paths.
1 parent 682efa5 commit 9ead587

17 files changed

+27
-44
lines changed

packages/replay/.eslintrc.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ module.exports = {
6060
files: ['test/**/*.ts'],
6161

6262
rules: {
63-
// TODO: decide if we want to keep our '@test' import paths
64-
'import/no-unresolved': 'off',
6563
// most of these errors come from `new Promise(process.nextTick)`
6664
'@typescript-eslint/unbound-method': 'off',
6765
// TODO: decide if we want to enable this again after the migration

packages/replay/jest.config.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import type { Config } from '@jest/types';
2-
import { pathsToModuleNameMapper } from 'ts-jest';
32
import { jsWithTs as jsWithTsPreset } from 'ts-jest/presets';
43

5-
import { compilerOptions } from './tsconfig.test.json';
6-
74
export default async (): Promise<Config.InitialOptions> => {
85
return {
96
...jsWithTsPreset,
@@ -14,9 +11,6 @@ export default async (): Promise<Config.InitialOptions> => {
1411
},
1512
__DEBUG_BUILD__: true,
1613
},
17-
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
18-
prefix: '<rootDir>/',
19-
}),
2014
setupFilesAfterEnv: ['./jest.setup.ts'],
2115
testEnvironment: 'jsdom',
2216
testMatch: ['<rootDir>/test/**/*(*.)@(spec|test).ts'],

packages/replay/test/mocks/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { getCurrentHub } from '@sentry/core';
2-
import { BASE_TIMESTAMP, RecordMock } from '@test';
3-
import { DomHandler, MockTransportSend } from '@test/types';
4-
import { Replay } from 'src';
52

63
import { ReplayConfiguration } from '../../src/types';
4+
import { BASE_TIMESTAMP, RecordMock } from './..';
5+
import { Replay } from './../../src';
6+
import { DomHandler, MockTransportSend } from './../types';
77

88
export async function resetSdkMock(options?: ReplayConfiguration): Promise<{
99
domHandler: DomHandler;

packages/replay/test/unit/coreHandlers/handleFetch.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { mockSdk } from '@test';
2-
31
import { handleFetch } from '../../../src/coreHandlers/handleFetch';
2+
import { mockSdk } from './../..';
43

54
jest.unmock('@sentry/browser');
65

packages/replay/test/unit/coreHandlers/handleScope-unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { getCurrentHub } from '@sentry/core';
2-
import { mockSdk } from '@test';
32

43
import * as HandleScope from '../../../src/coreHandlers/handleScope';
4+
import { mockSdk } from './../..';
55

66
let mockHandleScope: jest.MockedFunction<typeof HandleScope.handleScope>;
77

packages/replay/test/unit/createPerformanceEntry.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { mockSdk } from '@test';
2-
31
import { createPerformanceEntries } from '../../src/createPerformanceEntry';
2+
import { mockSdk } from './..';
43

54
jest.unmock('@sentry/browser');
65

packages/replay/test/unit/eventBuffer.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import 'jsdom-worker';
22

3-
import { BASE_TIMESTAMP } from '@test';
43
import pako from 'pako';
54

5+
import { BASE_TIMESTAMP } from './..';
66
import { createEventBuffer, EventBufferCompressionWorker } from './../../src/eventBuffer';
77

88
const TEST_EVENT = { data: {}, timestamp: BASE_TIMESTAMP, type: 3 };

packages/replay/test/unit/flush.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as SentryUtils from '@sentry/utils';
2-
import { BASE_TIMESTAMP, mockRrweb, mockSdk } from '@test';
32

43
import { SESSION_IDLE_DURATION, WINDOW } from '../../src/constants';
4+
import { BASE_TIMESTAMP, mockRrweb, mockSdk } from './..';
55
import { Replay } from './../../src';
66
import { createPerformanceEntries } from './../../src/createPerformanceEntry';
77
import { useFakeTimers } from './../../test/utils/use-fake-timers';

packages/replay/test/unit/index-errorSampleRate.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
jest.unmock('@sentry/browser');
22

33
import { captureException } from '@sentry/browser';
4-
import { BASE_TIMESTAMP, RecordMock } from '@test';
5-
import { PerformanceEntryResource } from '@test/fixtures/performanceEntry/resource';
6-
import { resetSdkMock } from '@test/mocks';
7-
import { DomHandler, MockTransportSend } from '@test/types';
84

95
import { REPLAY_SESSION_KEY, VISIBILITY_CHANGE_TIMEOUT, WINDOW } from '../../src/constants';
6+
import { BASE_TIMESTAMP, RecordMock } from './..';
107
import { Replay } from './../../src';
8+
import { PerformanceEntryResource } from './../fixtures/performanceEntry/resource';
9+
import { resetSdkMock } from './../mocks';
10+
import { DomHandler, MockTransportSend } from './../types';
1111
import { useFakeTimers } from './../utils/use-fake-timers';
1212

1313
useFakeTimers();

packages/replay/test/unit/index-handleGlobalEvent.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { getCurrentHub } from '@sentry/core';
2-
import { Error } from '@test/fixtures/error';
3-
import { Transaction } from '@test/fixtures/transaction';
4-
import { resetSdkMock } from '@test/mocks';
52

63
import { REPLAY_EVENT_NAME } from '../../src/constants';
74
import { Replay } from './../../src';
5+
import { Error } from './../fixtures/error';
6+
import { Transaction } from './../fixtures/transaction';
7+
import { resetSdkMock } from './../mocks';
88
import { useFakeTimers } from './../utils/use-fake-timers';
99

1010
useFakeTimers();

packages/replay/test/unit/index-integrationSettings.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { mockSdk } from '@test';
2-
31
import { Replay } from '../../src';
2+
import { mockSdk } from './..';
43

54
let replay: Replay;
65

packages/replay/test/unit/index-noSticky.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { getCurrentHub } from '@sentry/core';
22
import { Transport } from '@sentry/types';
33
import * as SentryUtils from '@sentry/utils';
4-
import { BASE_TIMESTAMP, mockRrweb, mockSdk } from '@test';
54

65
import { SESSION_IDLE_DURATION, VISIBILITY_CHANGE_TIMEOUT } from '../../src/constants';
6+
import { BASE_TIMESTAMP, mockRrweb, mockSdk } from './..';
77
import { Replay } from './../../src';
88
import { useFakeTimers } from './../utils/use-fake-timers';
99

packages/replay/test/unit/index-sampling.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
jest.unmock('@sentry/browser');
22

33
// mock functions need to be imported first
4-
import { mockRrweb, mockSdk } from '@test';
5-
4+
import { mockRrweb, mockSdk } from './..';
65
import { useFakeTimers } from './../utils/use-fake-timers';
76

87
useFakeTimers();

packages/replay/test/unit/index.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
jest.mock('./../../src/util/isInternal', () => ({
22
isInternal: jest.fn(() => true),
33
}));
4-
import { BASE_TIMESTAMP, RecordMock } from '@test';
5-
import { PerformanceEntryResource } from '@test/fixtures/performanceEntry/resource';
6-
import { resetSdkMock } from '@test/mocks';
7-
import { DomHandler, MockTransportSend } from '@test/types';
84
import { EventType } from 'rrweb';
95

106
import { Replay } from '../../src';
117
import { MAX_SESSION_LIFE, REPLAY_SESSION_KEY, VISIBILITY_CHANGE_TIMEOUT, WINDOW } from '../../src/constants';
128
import { RecordingEvent } from '../../src/types';
139
import { useFakeTimers } from '../utils/use-fake-timers';
10+
import { BASE_TIMESTAMP, RecordMock } from './..';
11+
import { PerformanceEntryResource } from './../fixtures/performanceEntry/resource';
12+
import { resetSdkMock } from './../mocks';
13+
import { DomHandler, MockTransportSend } from './../types';
1414

1515
useFakeTimers();
1616

packages/replay/test/unit/stop.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as SentryUtils from '@sentry/utils';
2-
// mock functions need to be imported first
3-
import { BASE_TIMESTAMP, mockRrweb, mockSdk } from '@test';
42

53
import { SESSION_IDLE_DURATION, WINDOW } from '../../src/constants';
4+
// mock functions need to be imported first
5+
import { BASE_TIMESTAMP, mockRrweb, mockSdk } from './..';
66
import { Replay } from './../../src';
77
import { useFakeTimers } from './../utils/use-fake-timers';
88

packages/replay/test/unit/util/dedupePerformanceEntries.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// eslint-disable-next-line import/no-unresolved
2-
import { PerformanceEntryLcp } from '@test/fixtures/performanceEntry/lcp';
3-
import { PerformanceEntryNavigation } from '@test/fixtures/performanceEntry/navigation';
4-
import { PerformanceEntryResource } from '@test/fixtures/performanceEntry/resource';
5-
62
import { dedupePerformanceEntries } from '../../../src/util/dedupePerformanceEntries';
3+
import { PerformanceEntryLcp } from './../../fixtures/performanceEntry/lcp';
4+
import { PerformanceEntryNavigation } from './../../fixtures/performanceEntry/navigation';
5+
import { PerformanceEntryResource } from './../../fixtures/performanceEntry/resource';
76

87
it('does nothing with a single entry', function () {
98
const entries = [PerformanceEntryNavigation()];

packages/replay/tsconfig.test.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
"include": ["test/**/*.ts", "jest.config.ts", "jest.setup.ts"],
55

66
"compilerOptions": {
7-
"paths": {
8-
"@test": ["./test"],
9-
"@test/*": ["./test/*"]
10-
},
117
"baseUrl": ".",
128
"rootDir": ".",
139
"types": ["node", "jest"],

0 commit comments

Comments
 (0)