Skip to content

Commit f34f3d1

Browse files
committed
fix: add missing packageManager property to test objects
The AutoConfigDetailsBase type now requires packageManager, but several test files were constructing AutoConfigDetails without it. Also updated vi.mock calls to preserve NpmPackageManager export and fixed a consistent-type-imports lint violation in setup.test.ts.
1 parent f0e6ec2 commit f34f3d1

5 files changed

Lines changed: 53 additions & 3 deletions

File tree

packages/wrangler/src/__tests__/autoconfig/details/confirm-auto-config-details.test.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import { describe, test, vi } from "vitest";
22
import { confirmAutoConfigDetails } from "../../../autoconfig/details";
33
import { Astro } from "../../../autoconfig/frameworks/astro";
44
import { Static } from "../../../autoconfig/frameworks/static";
5+
import { NpmPackageManager } from "../../../package-manager";
56
import {
67
mockConfirm,
78
mockPrompt,
89
mockSelect,
910
} from "../../helpers/mock-dialogs";
1011
import { useMockIsTTY } from "../../helpers/mock-istty";
1112

12-
vi.mock("../../../package-manager", () => ({
13+
vi.mock("../../../package-manager", async (importOriginal) => ({
14+
...(await importOriginal()),
1315
getPackageManager() {
1416
return {
1517
type: "npm",
@@ -36,6 +38,7 @@ describe("autoconfig details - confirmAutoConfigDetails()", () => {
3638
configured: false,
3739
framework: new Static({ id: "static", name: "Static" }),
3840
outputDir: "./public",
41+
packageManager: NpmPackageManager,
3942
});
4043

4144
expect(updatedAutoConfigDetails).toMatchInlineSnapshot(`
@@ -49,6 +52,13 @@ describe("autoconfig details - confirmAutoConfigDetails()", () => {
4952
"name": "Static",
5053
},
5154
"outputDir": "./public",
55+
"packageManager": Object {
56+
"dlx": Array [
57+
"npx",
58+
],
59+
"npx": "npx",
60+
"type": "npm",
61+
},
5262
"projectPath": "<PROJECT_PATH>",
5363
"workerName": "worker-name",
5464
}
@@ -88,6 +98,7 @@ describe("autoconfig details - confirmAutoConfigDetails()", () => {
8898
projectPath: "<PROJECT_PATH>",
8999
configured: false,
90100
framework: new Static({ id: "static", name: "Static" }),
101+
packageManager: NpmPackageManager,
91102
});
92103
expect(updatedAutoConfigDetails).toMatchInlineSnapshot(`
93104
Object {
@@ -100,6 +111,13 @@ describe("autoconfig details - confirmAutoConfigDetails()", () => {
100111
"name": "Static",
101112
},
102113
"outputDir": "./_public_",
114+
"packageManager": Object {
115+
"dlx": Array [
116+
"npx",
117+
],
118+
"npx": "npx",
119+
"type": "npm",
120+
},
103121
"projectPath": "<PROJECT_PATH>",
104122
"workerName": "new-name",
105123
}
@@ -139,6 +157,7 @@ describe("autoconfig details - confirmAutoConfigDetails()", () => {
139157
outputDir: "<OUTPUT_DIR>",
140158
projectPath: "<PROJECT_PATH>",
141159
configured: false,
160+
packageManager: NpmPackageManager,
142161
});
143162
expect(updatedAutoConfigDetails).toMatchInlineSnapshot(`
144163
Object {
@@ -151,6 +170,13 @@ describe("autoconfig details - confirmAutoConfigDetails()", () => {
151170
"name": "Astro",
152171
},
153172
"outputDir": "",
173+
"packageManager": Object {
174+
"dlx": Array [
175+
"npx",
176+
],
177+
"npx": "npx",
178+
"type": "npm",
179+
},
154180
"projectPath": "<PROJECT_PATH>",
155181
"workerName": "my-astro-worker",
156182
}
@@ -190,6 +216,7 @@ describe("autoconfig details - confirmAutoConfigDetails()", () => {
190216
outputDir: "<OUTPUT_DIR>",
191217
projectPath: "<PROJECT_PATH>",
192218
configured: false,
219+
packageManager: NpmPackageManager,
193220
});
194221

195222
expect(updatedAutoConfigDetails.framework?.id).toBe("nuxt");
@@ -210,6 +237,7 @@ describe("autoconfig details - confirmAutoConfigDetails()", () => {
210237
configured: false,
211238
framework: new Static({ id: "static", name: "Static" }),
212239
outputDir: "./public",
240+
packageManager: NpmPackageManager,
213241
});
214242

215243
expect(updatedAutoConfigDetails).toMatchInlineSnapshot(`
@@ -223,6 +251,13 @@ describe("autoconfig details - confirmAutoConfigDetails()", () => {
223251
"name": "Static",
224252
},
225253
"outputDir": "./public",
254+
"packageManager": Object {
255+
"dlx": Array [
256+
"npx",
257+
],
258+
"npx": "npx",
259+
"type": "npm",
260+
},
226261
"projectPath": "<PROJECT_PATH>",
227262
"workerName": "worker-name",
228263
}

packages/wrangler/src/__tests__/autoconfig/details/display-auto-config-details.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { describe, it, vi } from "vitest";
22
import { displayAutoConfigDetails } from "../../../autoconfig/details";
33
import { Static } from "../../../autoconfig/frameworks/static";
4+
import { NpmPackageManager } from "../../../package-manager";
45
import { mockConsoleMethods } from "../../helpers/mock-console";
56
import type { Framework } from "../../../autoconfig/frameworks";
67

7-
vi.mock("../../../package-manager", () => ({
8+
vi.mock("../../../package-manager", async (importOriginal) => ({
9+
...(await importOriginal()),
810
getPackageManager() {
911
return {
1012
type: "npm",
@@ -25,6 +27,7 @@ describe("autoconfig details - displayAutoConfigDetails()", () => {
2527
workerName: "my-project",
2628
framework: new Static({ id: "static", name: "Static" }),
2729
outputDir: "./public",
30+
packageManager: NpmPackageManager,
2831
});
2932
expect(std.out).toMatchInlineSnapshot(
3033
`
@@ -57,6 +60,7 @@ describe("autoconfig details - displayAutoConfigDetails()", () => {
5760
},
5861
buildCommand: "astro build",
5962
outputDir: "dist",
63+
packageManager: NpmPackageManager,
6064
});
6165
expect(std.out).toMatchInlineSnapshot(`
6266
"
@@ -78,6 +82,7 @@ describe("autoconfig details - displayAutoConfigDetails()", () => {
7882
workerName: "my-site",
7983
outputDir: "dist",
8084
framework: new Static({ id: "static", name: "Static" }),
85+
packageManager: NpmPackageManager,
8186
});
8287
expect(std.out).toMatchInlineSnapshot(`
8388
"

packages/wrangler/src/__tests__/autoconfig/run-summary.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { beforeEach, describe, test } from "vitest";
22
import { Astro } from "../../autoconfig/frameworks/astro";
33
import { Static } from "../../autoconfig/frameworks/static";
44
import { buildOperationsSummary } from "../../autoconfig/run";
5+
import { NpmPackageManager } from "../../package-manager";
56
import { dedent } from "../../utils/dedent";
67
import { mockConsoleMethods } from "../helpers/mock-console";
78
import { useMockIsTTY } from "../helpers/mock-istty";
@@ -34,6 +35,7 @@ describe("autoconfig run - buildOperationsSummary()", () => {
3435
configured: false,
3536
outputDir: "public",
3637
framework: new Static({ id: "static", name: "Static" }),
38+
packageManager: NpmPackageManager,
3739
},
3840
testRawConfig,
3941
{
@@ -92,6 +94,7 @@ describe("autoconfig run - buildOperationsSummary()", () => {
9294
configured: false,
9395
outputDir: "dist",
9496
framework: new Static({ id: "static", name: "Static" }),
97+
packageManager: NpmPackageManager,
9598
},
9699
testRawConfig,
97100
{
@@ -148,6 +151,7 @@ describe("autoconfig run - buildOperationsSummary()", () => {
148151
configured: false,
149152
outputDir: "out",
150153
framework: new Static({ id: "static", name: "Static" }),
154+
packageManager: NpmPackageManager,
151155
},
152156
testRawConfig,
153157
{
@@ -198,6 +202,7 @@ describe("autoconfig run - buildOperationsSummary()", () => {
198202
framework: new Astro({ id: "astro", name: "Astro" }),
199203
configured: false,
200204
outputDir: "dist",
205+
packageManager: NpmPackageManager,
201206
},
202207
testRawConfig,
203208
{
@@ -227,6 +232,7 @@ describe("autoconfig run - buildOperationsSummary()", () => {
227232
framework: new Static({ id: "static", name: "Static" }),
228233
configured: false,
229234
outputDir: "public",
235+
packageManager: NpmPackageManager,
230236
},
231237
testRawConfig,
232238
{

packages/wrangler/src/__tests__/deploy.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { getInstalledPackageVersion } from "../autoconfig/frameworks/utils/packa
2929
import { runAutoConfig } from "../autoconfig/run";
3030
import { printBundleSize } from "../deployment-bundle/bundle-reporter";
3131
import { clearOutputFilePath } from "../output";
32+
import { NpmPackageManager } from "../package-manager";
3233
import { getSubdomainValues } from "../triggers/deploy";
3334
import { writeAuthConfigFile } from "../user";
3435
import { fetchSecrets } from "../utils/fetch-secrets";
@@ -599,6 +600,7 @@ describe("deploy", () => {
599600
isConfigured: () => false,
600601
},
601602
outputDir: "public",
603+
packageManager: NpmPackageManager,
602604
});
603605

604606
mockConfirm({
@@ -637,6 +639,7 @@ describe("deploy", () => {
637639
isConfigured: () => false,
638640
},
639641
outputDir: "public",
642+
packageManager: NpmPackageManager,
640643
});
641644

642645
// The command will fail later due to missing entry-point, but we can still verify
@@ -15947,6 +15950,7 @@ export default{
1594715950
workerName: "my-site",
1594815951
projectPath: ".",
1594915952
outputDir: "./public",
15953+
packageManager: NpmPackageManager,
1595015954
});
1595115955

1595215956
vi.mocked(runAutoConfig).mockImplementation(async () => {

packages/wrangler/src/__tests__/setup.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { runWrangler } from "./helpers/run-wrangler";
1010
import type { OutputEntry } from "../output";
1111

1212
vi.mock("../package-manager", async (importOriginal) => {
13-
const actual = await importOriginal<typeof import("../package-manager")>();
13+
const actual = (await importOriginal()) as Record<string, unknown>;
1414
return {
1515
...actual,
1616
getPackageManager() {

0 commit comments

Comments
 (0)