Skip to content

Commit 3695427

Browse files
committed
build: update jest, ts-jest to latest versions
1 parent 0830866 commit 3695427

36 files changed

+1093
-907
lines changed

jest/jest.config.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,23 @@ module.exports = {
33
rootDir: process.cwd(),
44
collectCoverage: true,
55
transform: {
6-
'^.+\\.ts$': 'ts-jest',
7-
'^.+\\.tsx$': 'ts-jest',
6+
'^.+\\.ts$': [
7+
'ts-jest',
8+
{
9+
tsconfig: '<rootDir>/tsconfig.test.json',
10+
},
11+
],
12+
'^.+\\.tsx$': [
13+
'ts-jest',
14+
{
15+
tsconfig: '<rootDir>/tsconfig.test.json',
16+
},
17+
],
818
},
919
coverageDirectory: '<rootDir>/coverage',
1020
moduleFileExtensions: ['js', 'ts', 'tsx'],
1121
testMatch: ['<rootDir>/**/*.test.ts', '<rootDir>/**/*.test.tsx'],
1222
globals: {
13-
'ts-jest': {
14-
tsconfig: '<rootDir>/tsconfig.test.json',
15-
},
1623
__DEBUG_BUILD__: true,
1724
},
1825
testPathIgnorePatterns: ['<rootDir>/build/', '<rootDir>/node_modules/'],

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
"@size-limit/webpack": "~9.0.0",
9393
"@strictsoftware/typedoc-plugin-monorepo": "^0.3.1",
9494
"@types/chai": "^4.1.3",
95-
"@types/jest": "^27.4.1",
95+
"@types/jest": "^29.5.10",
9696
"@types/jsdom": "^16.2.3",
9797
"@types/mocha": "^5.2.0",
9898
"@types/node": "~10.17.0",
@@ -106,8 +106,9 @@
106106
"downlevel-dts": "~0.11.0",
107107
"es-check": "7.1.0",
108108
"eslint": "7.32.0",
109-
"jest": "^27.5.1",
110-
"jest-environment-node": "^27.5.1",
109+
"jest": "^29.7.0",
110+
"jest-environment-jsdom": "^29.7.0",
111+
"jest-environment-node": "^29.7.0",
111112
"jsdom": "^19.0.0",
112113
"karma-browserstack-launcher": "^1.5.1",
113114
"karma-firefox-launcher": "^1.1.0",
@@ -125,7 +126,7 @@
125126
"rollup-plugin-terser": "^7.0.2",
126127
"sinon": "^7.3.2",
127128
"size-limit": "~9.0.0",
128-
"ts-jest": "^27.1.4",
129+
"ts-jest": "^29.1.1",
129130
"ts-node": "10.9.1",
130131
"typedoc": "^0.18.0",
131132
"typescript": "4.9.5",

packages/angular/test/errorhandler.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ describe('SentryErrorHandler', () => {
516516
// this simulates the afterSend hook being called
517517
client.cb({});
518518

519-
expect(showReportDialogSpy).toBeCalledTimes(1);
519+
expect(showReportDialogSpy).toHaveBeenCalledTimes(1);
520520
});
521521

522522
it('by just calling `showReportDialog` if hooks are not available', () => {
@@ -525,7 +525,7 @@ describe('SentryErrorHandler', () => {
525525
const errorHandler = createErrorHandler({ showDialog: true });
526526
errorHandler.handleError(new Error('test'));
527527

528-
expect(showReportDialogSpy).toBeCalledTimes(1);
528+
expect(showReportDialogSpy).toHaveBeenCalledTimes(1);
529529
});
530530
});
531531
});

packages/angular/test/sdk.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import * as SentryBrowser from '@sentry/browser';
2+
import type { BrowserTransportOptions } from '@sentry/browser/src/transports/types';
3+
import type { Options } from '@sentry/types';
24

35
import { defaultIntegrations, init } from '../src/index';
46

@@ -26,19 +28,19 @@ describe('init', () => {
2628

2729
expect(browserInitSpy).toHaveBeenCalledTimes(1);
2830

29-
const options = browserInitSpy.mock.calls[0][0] || {};
30-
expect(options.defaultIntegrations).not.toContainEqual(expect.objectContaining({ name: 'TryCatch' }));
31+
const options = browserInitSpy.mock.calls[0][0] as Options<BrowserTransportOptions> | undefined;
32+
expect(options?.defaultIntegrations).not.toContainEqual(expect.objectContaining({ name: 'TryCatch' }));
3133
});
3234

3335
it.each([false as const, defaultIntegrations])(
3436
"doesn't filter if `defaultIntegrations` is set to %s",
35-
defaultIntegrations => {
37+
(defaultIntegrations: Options<BrowserTransportOptions>['defaultIntegrations']) => {
3638
init({ defaultIntegrations });
3739

3840
expect(browserInitSpy).toHaveBeenCalledTimes(1);
3941

40-
const options = browserInitSpy.mock.calls[0][0] || {};
41-
expect(options.defaultIntegrations).toEqual(defaultIntegrations);
42+
const options = browserInitSpy.mock.calls[0][0] as Options<BrowserTransportOptions> | undefined;
43+
expect(options?.defaultIntegrations).toEqual(defaultIntegrations);
4244
},
4345
);
4446
});

packages/angular/test/tracing.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component } from '@angular/core';
2-
import type { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot } from '@angular/router';
2+
import type { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot, Routes } from '@angular/router';
33
import type { Hub } from '@sentry/types';
44

55
import { TraceClassDecorator, TraceDirective, TraceMethodDecorator, instrumentAngularRouting } from '../src';
@@ -99,10 +99,8 @@ describe('Angular Tracing', () => {
9999
},
100100
'/users/:id/',
101101
],
102-
])('%s', (_, routeSnapshot, expectedParams) => {
103-
expect(getParameterizedRouteFromSnapshot(routeSnapshot as unknown as ActivatedRouteSnapshot)).toEqual(
104-
expectedParams,
105-
);
102+
])('%s', (_: unknown, routeSnapshot: ActivatedRouteSnapshot, expectedParams: unknown) => {
103+
expect(getParameterizedRouteFromSnapshot(routeSnapshot)).toEqual(expectedParams);
106104
});
107105
});
108106

@@ -316,7 +314,7 @@ describe('Angular Tracing', () => {
316314
},
317315
],
318316
],
319-
])('%s and sets the source to `route`', async (_, url, result, routes) => {
317+
])('%s and sets the source to `route`', async (_: unknown, url: string, result: string, routes: Routes) => {
320318
const customStartTransaction = jest.fn(defaultStartTransaction);
321319
const env = await TestEnv.setup({
322320
customStartTransaction,

packages/browser/test/unit/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ describe('SentryBrowser initialization', () => {
357357
const sdkData = getClient()?.getOptions()._metadata?.sdk || {};
358358

359359
expect(sdkData.packages?.[0].name).toBe('cdn:@sentry/browser');
360-
expect(utils.getSDKSource).toBeCalledTimes(1);
360+
expect(utils.getSDKSource).toHaveBeenCalledTimes(1);
361361
spy.mockRestore();
362362
});
363363

packages/core/test/lib/base.test.ts

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -996,8 +996,8 @@ describe('BaseClient', () => {
996996
expect(TestClient.instance!.event).toBeUndefined();
997997
// This proves that the reason the event didn't send/didn't get set on the test client is not because there was an
998998
// error, but because `beforeSend` returned `null`
999-
expect(captureExceptionSpy).not.toBeCalled();
1000-
expect(loggerWarnSpy).toBeCalledWith('before send for type `error` returned `null`, will not send event.');
999+
expect(captureExceptionSpy).not.toHaveBeenCalled();
1000+
expect(loggerWarnSpy).toHaveBeenCalledWith('before send for type `error` returned `null`, will not send event.');
10011001
});
10021002

10031003
test('calls `beforeSendTransaction` and discards the event', () => {
@@ -1015,8 +1015,10 @@ describe('BaseClient', () => {
10151015
expect(TestClient.instance!.event).toBeUndefined();
10161016
// This proves that the reason the event didn't send/didn't get set on the test client is not because there was an
10171017
// error, but because `beforeSendTransaction` returned `null`
1018-
expect(captureExceptionSpy).not.toBeCalled();
1019-
expect(loggerWarnSpy).toBeCalledWith('before send for type `transaction` returned `null`, will not send event.');
1018+
expect(captureExceptionSpy).not.toHaveBeenCalled();
1019+
expect(loggerWarnSpy).toHaveBeenCalledWith(
1020+
'before send for type `transaction` returned `null`, will not send event.',
1021+
);
10201022
});
10211023

10221024
test('calls `beforeSend` and logs info about invalid return value', () => {
@@ -1034,7 +1036,7 @@ describe('BaseClient', () => {
10341036

10351037
expect(beforeSend).toHaveBeenCalled();
10361038
expect(TestClient.instance!.event).toBeUndefined();
1037-
expect(loggerWarnSpy).toBeCalledWith(
1039+
expect(loggerWarnSpy).toHaveBeenCalledWith(
10381040
new SentryError('before send for type `error` must return `null` or a valid event.'),
10391041
);
10401042
}
@@ -1055,7 +1057,7 @@ describe('BaseClient', () => {
10551057

10561058
expect(beforeSendTransaction).toHaveBeenCalled();
10571059
expect(TestClient.instance!.event).toBeUndefined();
1058-
expect(loggerWarnSpy).toBeCalledWith(
1060+
expect(loggerWarnSpy).toHaveBeenCalledWith(
10591061
new SentryError('before send for type `transaction` must return `null` or a valid event.'),
10601062
);
10611063
}
@@ -1317,8 +1319,8 @@ describe('BaseClient', () => {
13171319
expect(TestClient.instance!.event).toBeUndefined();
13181320
// This proves that the reason the event didn't send/didn't get set on the test client is not because there was an
13191321
// error, but because the event processor returned `null`
1320-
expect(captureExceptionSpy).not.toBeCalled();
1321-
expect(loggerLogSpy).toBeCalledWith('An event processor returned `null`, will not send event.');
1322+
expect(captureExceptionSpy).not.toHaveBeenCalled();
1323+
expect(loggerLogSpy).toHaveBeenCalledWith('An event processor returned `null`, will not send event.');
13221324
});
13231325

13241326
test('event processor drops transaction event when it returns `null`', () => {
@@ -1335,8 +1337,8 @@ describe('BaseClient', () => {
13351337
expect(TestClient.instance!.event).toBeUndefined();
13361338
// This proves that the reason the event didn't send/didn't get set on the test client is not because there was an
13371339
// error, but because the event processor returned `null`
1338-
expect(captureExceptionSpy).not.toBeCalled();
1339-
expect(loggerLogSpy).toBeCalledWith('An event processor returned `null`, will not send event.');
1340+
expect(captureExceptionSpy).not.toHaveBeenCalled();
1341+
expect(loggerLogSpy).toHaveBeenCalledWith('An event processor returned `null`, will not send event.');
13401342
});
13411343

13421344
test('event processor records dropped error events', () => {
@@ -1440,13 +1442,13 @@ describe('BaseClient', () => {
14401442
client.captureEvent({ message: 'hello' }, {}, scope);
14411443

14421444
expect(TestClient.instance!.event!.exception!.values![0]).toStrictEqual({ type: 'Error', value: 'sorry' });
1443-
expect(captureExceptionSpy).toBeCalledWith(exception, {
1445+
expect(captureExceptionSpy).toHaveBeenCalledWith(exception, {
14441446
data: {
14451447
__sentry__: true,
14461448
},
14471449
originalException: exception,
14481450
});
1449-
expect(loggerWarnSpy).toBeCalledWith(
1451+
expect(loggerWarnSpy).toHaveBeenCalledWith(
14501452
new SentryError(
14511453
`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${exception}`,
14521454
),
@@ -1670,9 +1672,9 @@ describe('BaseClient', () => {
16701672
await undefined;
16711673
await undefined;
16721674

1673-
expect(mockSend).toBeCalledTimes(1);
1674-
expect(callback).toBeCalledTimes(1);
1675-
expect(callback).toBeCalledWith(errorEvent, {});
1675+
expect(mockSend).toHaveBeenCalledTimes(1);
1676+
expect(callback).toHaveBeenCalledTimes(1);
1677+
expect(callback).toHaveBeenCalledWith(errorEvent, {});
16761678
});
16771679

16781680
it('emits `afterSendEvent` when sending a transaction', async () => {
@@ -1698,9 +1700,9 @@ describe('BaseClient', () => {
16981700
await undefined;
16991701
await undefined;
17001702

1701-
expect(mockSend).toBeCalledTimes(1);
1702-
expect(callback).toBeCalledTimes(1);
1703-
expect(callback).toBeCalledWith(transactionEvent, {});
1703+
expect(mockSend).toHaveBeenCalledTimes(1);
1704+
expect(callback).toHaveBeenCalledTimes(1);
1705+
expect(callback).toHaveBeenCalledWith(transactionEvent, {});
17041706
});
17051707

17061708
it('still triggers `afterSendEvent` when transport.send rejects', async () => {
@@ -1730,9 +1732,9 @@ describe('BaseClient', () => {
17301732
await undefined;
17311733
await undefined;
17321734

1733-
expect(mockSend).toBeCalledTimes(1);
1734-
expect(callback).toBeCalledTimes(1);
1735-
expect(callback).toBeCalledWith(errorEvent, undefined);
1735+
expect(mockSend).toHaveBeenCalledTimes(1);
1736+
expect(callback).toHaveBeenCalledTimes(1);
1737+
expect(callback).toHaveBeenCalledWith(errorEvent, undefined);
17361738
});
17371739

17381740
it('passes the response to the hook', async () => {
@@ -1762,9 +1764,9 @@ describe('BaseClient', () => {
17621764
await undefined;
17631765
await undefined;
17641766

1765-
expect(mockSend).toBeCalledTimes(1);
1766-
expect(callback).toBeCalledTimes(1);
1767-
expect(callback).toBeCalledWith(errorEvent, { statusCode: 200 });
1767+
expect(mockSend).toHaveBeenCalledTimes(1);
1768+
expect(callback).toHaveBeenCalledTimes(1);
1769+
expect(callback).toHaveBeenCalledWith(errorEvent, { statusCode: 200 });
17681770
});
17691771
});
17701772

packages/deno/jest.config.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/deno/test/__snapshots__/mod.test.ts.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,35 @@ snapshot[`captureException 1`] = `
4646
filename: "ext:cli/40_testing.js",
4747
function: "outerWrapped",
4848
in_app: false,
49-
lineno: 488,
49+
lineno: 472,
5050
},
5151
{
5252
colno: 33,
5353
filename: "ext:cli/40_testing.js",
5454
function: "exitSanitizer",
5555
in_app: false,
56-
lineno: 474,
56+
lineno: 458,
5757
},
5858
{
5959
colno: 31,
6060
filename: "ext:cli/40_testing.js",
6161
function: "resourceSanitizer",
6262
in_app: false,
63-
lineno: 425,
63+
lineno: 410,
6464
},
6565
{
6666
colno: 33,
6767
filename: "ext:cli/40_testing.js",
6868
function: "asyncOpSanitizer",
6969
in_app: false,
70-
lineno: 192,
70+
lineno: 177,
7171
},
7272
{
7373
colno: 11,
7474
filename: "ext:cli/40_testing.js",
7575
function: "innerWrapped",
7676
in_app: false,
77-
lineno: 543,
77+
lineno: 526,
7878
},
7979
{
8080
colno: 24,

packages/gatsby/jest.config.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@ const baseConfig = require('../../jest/jest.config.js');
22

33
module.exports = {
44
...baseConfig,
5-
setupFiles: ['<rootDir>/test/setEnvVars.ts'],
6-
testEnvironment: 'jsdom',
5+
preset: 'ts-jest/presets/js-with-ts',
76
transform: {
8-
'^.+\\.js$': 'ts-jest',
9-
...baseConfig.transform,
7+
'^.+\\.ts$': [
8+
'ts-jest',
9+
{
10+
tsconfig: '<rootDir>/tsconfig.test.json',
11+
},
12+
],
13+
'^.+\\.js$': [
14+
'ts-jest',
15+
{
16+
tsconfig: '<rootDir>/tsconfig.test.json',
17+
},
18+
],
1019
},
20+
setupFiles: ['<rootDir>/test/setEnvVars.ts'],
21+
testEnvironment: 'jsdom',
1122
};

0 commit comments

Comments
 (0)