Skip to content

Commit 78f65e9

Browse files
committed
upgrade jest and fix broken tests
1 parent ee2c685 commit 78f65e9

File tree

11 files changed

+1382
-790
lines changed

11 files changed

+1382
-790
lines changed

package-lock.json

Lines changed: 1341 additions & 736 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,18 @@
5353
"@eslint/js": "^9.37.0",
5454
"@types/cookie": "^0.6.0",
5555
"@types/glob": "^8.1.0",
56-
"@types/jest": "^29.5.14",
56+
"@types/jest": "^30.0.0",
5757
"@types/node": "~20",
5858
"@types/pluralize": "0.0.33",
5959
"@types/qs": "^6.14.0",
6060
"@typescript-eslint/parser": "^8.46.0",
61-
"babel-jest": "^29.7.0",
61+
"babel-jest": "^30.2.0",
6262
"esbuild-fix-imports-plugin": "^1.0.21",
6363
"eslint": "^9.37.0",
6464
"eslint-plugin-jest": "^29.0.1",
6565
"eslint-plugin-n": "^17.23.1",
6666
"glob": "^11.0.3",
67-
"jest": "29.7.0",
67+
"jest": "30.2.0",
6868
"jest-environment-miniflare": "^2.14.2",
6969
"jest-fetch-mock": "^3.0.3",
7070
"miniflare": "^4.20251004.0",

src/audit-logs/audit-logs.spec.ts

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
serializeCreateAuditLogEventOptions,
1818
serializeCreateAuditLogSchemaOptions,
1919
} from './serializers';
20-
import { FetchError } from '../common/utils/fetch-error';
2120

2221
const event: CreateAuditLogEventOptions = {
2322
action: 'document.updated',
@@ -126,18 +125,14 @@ describe('AuditLogs', () => {
126125
const workosSpy = jest.spyOn(WorkOS.prototype, 'post');
127126

128127
workosSpy.mockImplementationOnce(() => {
129-
throw new FetchError({
130-
message:
131-
'Could not authorize the request. Maybe your API key is invalid?',
132-
response: { status: 401, headers: new Headers(), data: {} },
133-
});
128+
throw new UnauthorizedException('a-request-id');
134129
});
135130

136131
const workos = new WorkOS('invalid apikey');
137132

138133
await expect(
139134
workos.auditLogs.createEvent('org_123', event),
140-
).rejects.toThrowError(new UnauthorizedException('a-request-id'));
135+
).rejects.toThrow(UnauthorizedException);
141136
});
142137
});
143138

@@ -281,18 +276,14 @@ describe('AuditLogs', () => {
281276
};
282277

283278
workosSpy.mockImplementationOnce(() => {
284-
throw new FetchError({
285-
message:
286-
'Could not authorize the request. Maybe your API key is invalid?',
287-
response: { status: 401, headers: new Headers(), data: {} },
288-
});
279+
throw new UnauthorizedException('a-request-id');
289280
});
290281

291282
const workos = new WorkOS('invalid apikey');
292283

293284
await expect(
294285
workos.auditLogs.createExport(options),
295-
).rejects.toThrowError(new UnauthorizedException('a-request-id'));
286+
).rejects.toThrow(UnauthorizedException);
296287
});
297288
});
298289
});
@@ -343,18 +334,14 @@ describe('AuditLogs', () => {
343334
const workosSpy = jest.spyOn(WorkOS.prototype, 'get');
344335

345336
workosSpy.mockImplementationOnce(() => {
346-
throw new FetchError({
347-
message:
348-
'Could not authorize the request. Maybe your API key is invalid?',
349-
response: { status: 401, headers: new Headers(), data: {} },
350-
});
337+
throw new UnauthorizedException('a-request-id');
351338
});
352339

353340
const workos = new WorkOS('invalid apikey');
354341

355342
await expect(
356343
workos.auditLogs.getExport('audit_log_export_1234'),
357-
).rejects.toThrowError(new UnauthorizedException('a-request-id'));
344+
).rejects.toThrow(UnauthorizedException);
358345

359346
expect(workosSpy).toHaveBeenCalledWith(
360347
`/audit_logs/exports/audit_log_export_1234`,

src/common/net/fetch-client.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ describe('Fetch client', () => {
180180
const mockSleep = jest.spyOn(fetchClient, 'sleep');
181181
mockSleep.mockImplementation(() => Promise.resolve());
182182

183-
await expect(
184-
fetchClient.get('/fga/v1/resources', {}),
185-
).rejects.toThrowError('Gateway Timeout');
183+
await expect(fetchClient.get('/fga/v1/resources', {})).rejects.toThrow(
184+
'Gateway Timeout',
185+
);
186186

187187
expect(mockShouldRetryRequest).toHaveBeenCalledTimes(4);
188188
expect(mockSleep).toHaveBeenCalledTimes(3);
@@ -200,9 +200,9 @@ describe('Fetch client', () => {
200200
'shouldRetryRequest',
201201
);
202202

203-
await expect(
204-
fetchClient.get('/fga/v1/resources', {}),
205-
).rejects.toThrowError('Bad Request');
203+
await expect(fetchClient.get('/fga/v1/resources', {})).rejects.toThrow(
204+
'Bad Request',
205+
);
206206

207207
expect(mockShouldRetryRequest).toHaveBeenCalledTimes(1);
208208
});

src/organizations/organizations.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ describe('Organizations', () => {
202202
],
203203
name: 'Test Organization',
204204
}),
205-
).rejects.toThrowError(
205+
).rejects.toThrow(
206206
'An Organization with the domain example.com already exists.',
207207
);
208208
expect(fetchBody()).toEqual({
@@ -354,7 +354,7 @@ describe('Organizations', () => {
354354
organization: 'org_01EHT88Z8J8795GZNQ4ZP1J81T',
355355
stripeCustomerId: 'cus_MX8J9nfK4lP2Yw',
356356
}),
357-
).rejects.toThrowError(
357+
).rejects.toThrow(
358358
'stripe_customer_id is not enabled for this environment',
359359
);
360360

src/portal/portal.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ describe('Portal', () => {
151151
organization: 'bogus-id',
152152
returnUrl: 'https://www.example.com',
153153
}),
154-
).rejects.toThrowError(
154+
).rejects.toThrow(
155155
'Could not find an organization with the id, bogus-id.',
156156
);
157157
expect(fetchBody()).toEqual({
@@ -175,7 +175,7 @@ describe('Portal', () => {
175175
organization: 'bogus-id',
176176
returnUrl: 'https://www.example.com',
177177
}),
178-
).rejects.toThrowError(
178+
).rejects.toThrow(
179179
'Could not find an organization with the id, bogus-id.',
180180
);
181181
expect(fetchBody()).toEqual({

src/sso/__snapshots__/sso.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`SSO SSO getAuthorizationUrl with a connection generates an authorize url with the connection 1`] = `"https://api.workos.dev/sso/authorize?client_id=proj_123&connection=connection_123&redirect_uri=example.com%2Fsso%2Fworkos%2Fcallback&response_type=code"`;
44

src/user-management/__snapshots__/user-management.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`UserManagement getAuthorizationUrl with a code_challenge and code_challenge_method generates an authorize url 1`] = `"https://api.workos.com/user_management/authorize?client_id=proj_123&code_challenge=code_challenge_value&code_challenge_method=S256&provider=authkit&redirect_uri=example.com%2Fauth%2Fworkos%2Fcallback&response_type=code"`;
44

src/user-management/user-management.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2198,7 +2198,7 @@ describe('UserManagement', () => {
21982198

21992199
expect(() => {
22002200
workos.userManagement.getJwksUrl('');
2201-
}).toThrowError(TypeError);
2201+
}).toThrow(TypeError);
22022202
});
22032203
});
22042204
});

src/webhooks/webhooks.spec.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ describe('Webhooks', () => {
9999
const sigHeader = '';
100100
const options = { payload, sigHeader, secret };
101101

102-
await expect(
103-
workos.webhooks.constructEvent(options),
104-
).rejects.toThrowError(SignatureVerificationException);
102+
await expect(workos.webhooks.constructEvent(options)).rejects.toThrow(
103+
SignatureVerificationException,
104+
);
105105
});
106106
});
107107

@@ -110,9 +110,9 @@ describe('Webhooks', () => {
110110
const sigHeader = `t=${timestamp}, v1=`;
111111
const options = { payload, sigHeader, secret };
112112

113-
await expect(
114-
workos.webhooks.constructEvent(options),
115-
).rejects.toThrowError(SignatureVerificationException);
113+
await expect(workos.webhooks.constructEvent(options)).rejects.toThrow(
114+
SignatureVerificationException,
115+
);
116116
});
117117
});
118118

@@ -121,9 +121,9 @@ describe('Webhooks', () => {
121121
const sigHeader = `t=${timestamp}, v1=99999`;
122122
const options = { payload, sigHeader, secret };
123123

124-
await expect(
125-
workos.webhooks.constructEvent(options),
126-
).rejects.toThrowError(SignatureVerificationException);
124+
await expect(workos.webhooks.constructEvent(options)).rejects.toThrow(
125+
SignatureVerificationException,
126+
);
127127
});
128128
});
129129

@@ -133,9 +133,9 @@ describe('Webhooks', () => {
133133
payload = 'invalid';
134134
const options = { payload, sigHeader, secret };
135135

136-
await expect(
137-
workos.webhooks.constructEvent(options),
138-
).rejects.toThrowError(SignatureVerificationException);
136+
await expect(workos.webhooks.constructEvent(options)).rejects.toThrow(
137+
SignatureVerificationException,
138+
);
139139
});
140140
});
141141

@@ -145,9 +145,9 @@ describe('Webhooks', () => {
145145
secret = 'invalid';
146146
const options = { payload, sigHeader, secret };
147147

148-
await expect(
149-
workos.webhooks.constructEvent(options),
150-
).rejects.toThrowError(SignatureVerificationException);
148+
await expect(workos.webhooks.constructEvent(options)).rejects.toThrow(
149+
SignatureVerificationException,
150+
);
151151
});
152152
});
153153

@@ -156,9 +156,9 @@ describe('Webhooks', () => {
156156
const sigHeader = `t=9999, v1=${signatureHash}`;
157157
const options = { payload, sigHeader, secret };
158158

159-
await expect(
160-
workos.webhooks.constructEvent(options),
161-
).rejects.toThrowError(SignatureVerificationException);
159+
await expect(workos.webhooks.constructEvent(options)).rejects.toThrow(
160+
SignatureVerificationException,
161+
);
162162
});
163163
});
164164
});

0 commit comments

Comments
 (0)