Skip to content

Commit 8bfa111

Browse files
authored
build(replay): Streamline tsconfig & jest config (#6399)
* Move some tsconfig stuff we need for tests only to tsconfig.test.json * Add some more common folders to vscode search.exclude * Stop using @test imports in replay * Make replay tests non-verbose
1 parent 711bb7d commit 8bfa111

19 files changed

+37
-63
lines changed

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
"search.exclude": {
1111
"**/node_modules/": true,
1212
"**/build/": true,
13-
"**/dist/": true
13+
"**/dist/": true,
14+
"**/coverage/": true,
15+
"**/yarn-error.log": true
1416
},
1517
"typescript.tsdk": "./node_modules/typescript/lib",
1618
"[json]": {

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 & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
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,
10-
verbose: true,
117
globals: {
128
'ts-jest': {
139
tsconfig: '<rootDir>/tsconfig.test.json',
1410
},
1511
__DEBUG_BUILD__: true,
1612
},
17-
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
18-
prefix: '<rootDir>/',
19-
}),
2013
setupFilesAfterEnv: ['./jest.setup.ts'],
2114
testEnvironment: 'jsdom',
2215
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 { Replay } from './../../src';
5+
import { BASE_TIMESTAMP, RecordMock } from './../index';
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 './../../index';
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 './../../index';
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 './../index';
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,9 +1,9 @@
11
import 'jsdom-worker';
22

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

65
import { createEventBuffer, EventBufferCompressionWorker } from './../../src/eventBuffer';
6+
import { BASE_TIMESTAMP } from './../index';
77

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
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';
54
import { Replay } from './../../src';
65
import { createPerformanceEntries } from './../../src/createPerformanceEntry';
76
import { useFakeTimers } from './../../test/utils/use-fake-timers';
7+
import { BASE_TIMESTAMP, mockRrweb, mockSdk } from './../index';
88

99
useFakeTimers();
1010

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';
106
import { Replay } from './../../src';
7+
import { PerformanceEntryResource } from './../fixtures/performanceEntry/resource';
8+
import { BASE_TIMESTAMP, RecordMock } from './../index';
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 './../index';
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,10 +1,10 @@
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';
76
import { Replay } from './../../src';
7+
import { BASE_TIMESTAMP, mockRrweb, mockSdk } from './../index';
88
import { useFakeTimers } from './../utils/use-fake-timers';
99

1010
useFakeTimers();

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 './../index';
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 { PerformanceEntryResource } from './../fixtures/performanceEntry/resource';
11+
import { BASE_TIMESTAMP, RecordMock } from './../index';
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,9 +1,9 @@
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';
64
import { Replay } from './../../src';
5+
// mock functions need to be imported first
6+
import { BASE_TIMESTAMP, mockRrweb, mockSdk } from './../index';
77
import { useFakeTimers } from './../utils/use-fake-timers';
88

99
useFakeTimers();

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.json

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
{
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
4-
"module": "esnext",
5-
"noImplicitAny": true,
6-
"noEmitOnError": false,
7-
"esModuleInterop": true,
8-
"resolveJsonModule": true,
9-
"allowJs": true,
10-
"declaration": true,
11-
"declarationMap": true,
12-
"strictNullChecks": true
4+
"module": "esnext"
135
},
14-
"include": ["src/**/*.ts"],
15-
"exclude": ["node_modules"]
6+
"include": ["src/**/*.ts"]
167
}

packages/replay/tsconfig.test.json

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

66
"compilerOptions": {
7-
"paths": {
8-
"@test": ["./test"],
9-
"@test/*": ["./test/*"]
10-
},
11-
"baseUrl": ".",
12-
"rootDir": ".",
137
"types": ["node", "jest"],
14-
"noImplicitAny": false,
8+
"esModuleInterop": true,
9+
"allowJs": true,
10+
"noImplicitAny": true,
1511
"noImplicitThis": false,
16-
"strictPropertyInitialization": false,
17-
"resolveJsonModule": true,
18-
"allowJs": true
12+
"strictNullChecks": true,
13+
"strictPropertyInitialization": false
1914
}
2015
}

0 commit comments

Comments
 (0)