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();

0 commit comments

Comments
 (0)