Skip to content

Commit 9ba5bd8

Browse files
maxholmanclaude
andcommitted
chore: update deps, migrate tests to undici 8
Drop biome, prettier, eslint, @hapi/bourne. Upgrade to undici 8, vitest 4, vite 8, typescript 6. Tests now pass undici's fetch with mock dispatcher instead of relying on setGlobalDispatcher. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 600443b commit 9ba5bd8

5 files changed

Lines changed: 1052 additions & 3385 deletions

File tree

__tests__/openai.test.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1-
import { MockAgent, setGlobalDispatcher } from "undici";
2-
import { afterAll, beforeAll, describe, expect, test } from "vitest";
1+
import { MockAgent, fetch as undiciFetch } from "undici";
2+
import { describe, expect, test } from "vitest";
33
import { CreateModerationCommand } from "./fixtures/openai/commands.ts";
44
import { OpenAiApiRestClient } from "./fixtures/openai/main.ts";
55

66
const mockAgent = new MockAgent();
7-
setGlobalDispatcher(mockAgent);
8-
9-
beforeAll(() => {
10-
mockAgent.activate();
11-
mockAgent.disableNetConnect();
12-
});
13-
14-
afterAll(() => {
15-
mockAgent.assertNoPendingInterceptors();
16-
});
7+
mockAgent.disableNetConnect();
178

189
const apiUrl = "http://192.2.0.1";
1910

@@ -35,6 +26,8 @@ describe("OpenAI", () => {
3526
test("CreateModeration", async () => {
3627
const openAiClient = new OpenAiApiRestClient(apiUrl, {
3728
logger: console.debug,
29+
fetch: (input, init) =>
30+
undiciFetch(input, { ...init, dispatcher: mockAgent }),
3831
});
3932

4033
const command = new CreateModerationCommand({

__tests__/petstore.test.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
1-
import { MockAgent, setGlobalDispatcher } from "undici";
2-
import { afterAll, beforeAll, describe, expect, test, vi } from "vitest";
1+
import { MockAgent, fetch as undiciFetch } from "undici";
2+
import { describe, expect, test, vi } from "vitest";
33
import { FindPetsCommand } from "./fixtures/petstore/commands.ts";
44
import { SwaggerPetstoreRestClient } from "./fixtures/petstore/main.ts";
55

66
const mockAgent = new MockAgent();
7-
setGlobalDispatcher(mockAgent);
8-
9-
beforeAll(() => {
10-
mockAgent.activate();
11-
mockAgent.disableNetConnect();
12-
});
13-
14-
afterAll(() => {
15-
mockAgent.assertNoPendingInterceptors();
16-
});
17-
187
mockAgent.disableNetConnect();
8+
199
const apiUrl = "http://192.2.0.1";
2010

2111
describe("Petstore", () => {
@@ -26,7 +16,6 @@ describe("Petstore", () => {
2616
pool
2717
.intercept({
2818
path: "/pets?tags=tag1%2Ctag2&limit=10",
29-
// query: { limit: '10', tags: ['tag1', 'tag2'] },
3019
method: "GET",
3120
body(body) {
3221
bodySpy(body);
@@ -39,6 +28,8 @@ describe("Petstore", () => {
3928
test("find pets", async () => {
4029
const petStoreClient = new SwaggerPetstoreRestClient(apiUrl, {
4130
logger: console.log,
31+
fetch: (input, init) =>
32+
undiciFetch(input, { ...init, dispatcher: mockAgent }),
4233
});
4334
const command = new FindPetsCommand({
4435
limit: "10",

__tests__/test1.test.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
1-
import { MockAgent, setGlobalDispatcher } from "undici";
2-
import { afterAll, beforeAll, describe, expect, test, vi } from "vitest";
1+
import { MockAgent, fetch as undiciFetch } from "undici";
2+
import { describe, expect, test, vi } from "vitest";
33
import {
44
GetBillingAccountCommand,
55
ListBillingAccountsCommand,
66
} from "./fixtures/test1/commands.ts";
77
import { BillingServiceRestApiRestClient } from "./fixtures/test1/main.ts";
88

99
const mockAgent = new MockAgent();
10-
11-
beforeAll(() => {
12-
mockAgent.activate();
13-
mockAgent.disableNetConnect();
14-
setGlobalDispatcher(mockAgent);
15-
});
16-
17-
afterAll(() => {
18-
mockAgent.assertNoPendingInterceptors();
19-
});
20-
2110
mockAgent.disableNetConnect();
22-
// setGlobalDispatcher(mockAgent);
11+
2312
const apiUrl = "http://192.2.0.1";
2413

2514
describe("Test1", () => {
@@ -47,6 +36,8 @@ describe("Test1", () => {
4736
test("get billing account", async () => {
4837
const client = new BillingServiceRestApiRestClient(apiUrl, {
4938
logger: console.debug,
39+
fetch: (input, init) =>
40+
undiciFetch(input, { ...init, dispatcher: mockAgent }),
5041
});
5142
const command = new GetBillingAccountCommand({
5243
billingAccountId: "1234",

package.json

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,33 @@
2020
"preversion": "make test"
2121
},
2222
"dependencies": {
23-
"@apidevtools/json-schema-ref-parser": "^15.2.2",
23+
"@apidevtools/json-schema-ref-parser": "^15.3.5",
2424
"camelcase": "^9.0.0",
2525
"toposort": "^2.0.2",
26-
"ts-morph": "^27.0.2",
27-
"type-fest": "^5.0.0",
26+
"ts-morph": "^28.0.0",
27+
"type-fest": "^5.6.0",
2828
"word-wrap": "^1.2.5",
2929
"yargs": "^18.0.0"
3030
},
3131
"devDependencies": {
32-
"@biomejs/biome": "^2.0.0",
3332
"@block65/custom-error": "^14.0.0",
34-
"@block65/rest-client": "^12.1.0",
35-
"@hapi/bourne": "^3.0.0",
36-
"@ts-morph/common": "^0.28.1",
37-
"@tsconfig/node24": "^24.0.0",
38-
"@tsconfig/strictest": "^2.0.0",
39-
"@types/eslint": "^9.6.1",
40-
"@types/node": "^24.0.0",
33+
"@block65/rest-client": "^12.1.1",
34+
"@ts-morph/common": "^0.29.0",
35+
"@tsconfig/node24": "^24.0.4",
36+
"@tsconfig/strictest": "^2.0.8",
37+
"@types/node": "^25.6.0",
4138
"@types/toposort": "^2.0.7",
4239
"@types/yargs": "^17.0.35",
43-
"@typescript-eslint/eslint-plugin": "^8.53.1",
44-
"@typescript-eslint/parser": "^8.53.1",
45-
"eslint": "^9.0.0",
46-
"eslint-plugin-import": "^2.32.0",
47-
"hono": "^4.0.0",
40+
"hono": "^4.12.16",
4841
"js-yaml": "^4.1.1",
49-
"openapi3-ts": "^4.0.0",
50-
"prettier": "^3.8.1",
51-
"typescript": "^5.8.0",
52-
"undici": "^7.19.0",
53-
"valibot": "^1.0.0",
54-
"vitest": "^3.0.0"
42+
"openapi3-ts": "^4.5.0",
43+
"oxfmt": "^0.47.0",
44+
"oxlint": "^1.62.0",
45+
"typescript": "^6.0.3",
46+
"undici": "^8.2.0",
47+
"valibot": "^1.3.1",
48+
"vite": "^8.0.10",
49+
"vitest": "^4.1.5"
5550
},
5651
"peerDependencies": {
5752
"@block65/custom-error": "^14.0.0",

0 commit comments

Comments
 (0)