Skip to content

Commit 9f22dbe

Browse files
committed
Fix tests
1 parent 7a3ce53 commit 9f22dbe

File tree

7 files changed

+88
-83
lines changed

7 files changed

+88
-83
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ describe("autoconfig details - confirmAutoConfigDetails()", () => {
3131
});
3232

3333
expect(updatedAutoConfigDetails).toMatchInlineSnapshot(`
34-
Object {
35-
"buildCommand": "npm run build",
36-
"configured": false,
37-
"projectPath": "<PROJECT_PATH>",
38-
"workerName": "worker-name",
39-
}
40-
`);
34+
{
35+
"buildCommand": "npm run build",
36+
"configured": false,
37+
"projectPath": "<PROJECT_PATH>",
38+
"workerName": "worker-name",
39+
}
40+
`);
4141
});
4242

4343
test("settings can be updated in a plain static site without a framework nor a build script", async () => {
@@ -68,7 +68,7 @@ describe("autoconfig details - confirmAutoConfigDetails()", () => {
6868
configured: false,
6969
});
7070
expect(updatedAutoConfigDetails).toMatchInlineSnapshot(`
71-
Object {
71+
{
7272
"buildCommand": "npm run app:build",
7373
"configured": false,
7474
"outputDir": "./_public_",
@@ -111,10 +111,10 @@ describe("autoconfig details - confirmAutoConfigDetails()", () => {
111111
configured: false,
112112
});
113113
expect(updatedAutoConfigDetails).toMatchInlineSnapshot(`
114-
Object {
114+
{
115115
"buildCommand": "npm run build",
116116
"configured": false,
117-
"framework": Object {
117+
"framework": {
118118
"configure": [Function],
119119
"configured": false,
120120
"name": "astro",
@@ -139,7 +139,7 @@ describe("autoconfig details - confirmAutoConfigDetails()", () => {
139139
});
140140

141141
expect(updatedAutoConfigDetails).toMatchInlineSnapshot(`
142-
Object {
142+
{
143143
"buildCommand": "npm run build",
144144
"configured": false,
145145
"projectPath": "<PROJECT_PATH>",

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,24 @@ describe("autoconfig run - buildOperationsSummary()", () => {
3838
"
3939
📄 Create wrangler.jsonc:
4040
{
41-
\\"$schema\\": \\"node_modules/wrangler/config-schema.json\\",
42-
\\"name\\": \\"worker-name\\",
43-
\\"compatibility_date\\": \\"2025-01-01\\",
44-
\\"observability\\": {
45-
\\"enabled\\": true
41+
"$schema": "node_modules/wrangler/config-schema.json",
42+
"name": "worker-name",
43+
"compatibility_date": "2025-01-01",
44+
"observability": {
45+
"enabled": true
4646
}
4747
}
4848
"
4949
`);
5050

5151
expect(summary).toMatchInlineSnapshot(`
52-
Object {
53-
"scripts": Object {},
54-
"wranglerConfig": Object {
52+
{
53+
"scripts": {},
54+
"wranglerConfig": {
5555
"$schema": "node_modules/wrangler/config-schema.json",
5656
"compatibility_date": "2025-01-01",
5757
"name": "worker-name",
58-
"observability": Object {
58+
"observability": {
5959
"enabled": true,
6060
},
6161
},
@@ -86,16 +86,16 @@ describe("autoconfig run - buildOperationsSummary()", () => {
8686
);
8787

8888
expect(summary).toMatchInlineSnapshot(`
89-
Object {
90-
"scripts": Object {
89+
{
90+
"scripts": {
9191
"deploy": "wrangler deploy",
9292
"preview": "wrangler dev",
9393
},
94-
"wranglerConfig": Object {
94+
"wranglerConfig": {
9595
"$schema": "node_modules/wrangler/config-schema.json",
9696
"compatibility_date": "2025-01-01",
9797
"name": "worker-name",
98-
"observability": Object {
98+
"observability": {
9999
"enabled": true,
100100
},
101101
},
@@ -128,16 +128,16 @@ describe("autoconfig run - buildOperationsSummary()", () => {
128128
);
129129

130130
expect(summary).toMatchInlineSnapshot(`
131-
Object {
132-
"scripts": Object {
131+
{
132+
"scripts": {
133133
"deploy": "wrangler deploy",
134134
"preview": "wrangler dev",
135135
},
136-
"wranglerConfig": Object {
136+
"wranglerConfig": {
137137
"$schema": "node_modules/wrangler/config-schema.json",
138138
"compatibility_date": "2025-01-01",
139139
"name": "worker-name",
140-
"observability": Object {
140+
"observability": {
141141
"enabled": true,
142142
},
143143
},

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

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -154,22 +154,25 @@ describe("autoconfig (deploy)", () => {
154154
assets: { directory: outputDir },
155155
},
156156
}));
157-
await run.runAutoConfig({
158-
projectPath: process.cwd(),
159-
buildCommand: "echo 'built' > build.txt",
160-
configured: false,
161-
workerName: "my-worker",
162-
framework: {
163-
name: "Fake",
164-
configure: configureSpy,
165-
} as unknown as Framework,
166-
outputDir: "dist",
167-
packageJson: {
168-
dependencies: {
169-
astro: "5",
157+
await run.runAutoConfig(
158+
{
159+
projectPath: process.cwd(),
160+
buildCommand: "echo 'built' > build.txt",
161+
configured: false,
162+
workerName: "my-worker",
163+
framework: {
164+
name: "Fake",
165+
configure: configureSpy,
166+
} as unknown as Framework,
167+
outputDir: "dist",
168+
packageJson: {
169+
dependencies: {
170+
astro: "5",
171+
},
170172
},
171173
},
172-
});
174+
{ enableWranglerInstallation: true }
175+
);
173176

174177
expect(std.out).toMatchInlineSnapshot(`
175178
"
@@ -184,19 +187,19 @@ describe("autoconfig (deploy)", () => {
184187
- wrangler (devDependency)
185188
186189
📝 Update package.json scripts:
187-
- \\"deploy\\": \\"echo 'built' > build.txt && wrangler deploy\\"
188-
- \\"preview\\": \\"echo 'built' > build.txt && wrangler dev\\"
190+
- "deploy": "echo 'built' > build.txt && wrangler deploy"
191+
- "preview": "echo 'built' > build.txt && wrangler dev"
189192
190193
📄 Create wrangler.jsonc:
191194
{
192-
\\"$schema\\": \\"node_modules/wrangler/config-schema.json\\",
193-
\\"name\\": \\"my-worker\\",
194-
\\"compatibility_date\\": \\"2000-01-01\\",
195-
\\"observability\\": {
196-
\\"enabled\\": true
195+
"$schema": "node_modules/wrangler/config-schema.json",
196+
"name": "my-worker",
197+
"compatibility_date": "2000-01-01",
198+
"observability": {
199+
"enabled": true
197200
},
198-
\\"assets\\": {
199-
\\"directory\\": \\"dist\\"
201+
"assets": {
202+
"directory": "dist"
200203
}
201204
}
202205
@@ -207,14 +210,14 @@ describe("autoconfig (deploy)", () => {
207210

208211
expect(readFileSync("wrangler.jsonc")).toMatchInlineSnapshot(`
209212
"{
210-
\\"$schema\\": \\"node_modules/wrangler/config-schema.json\\",
211-
\\"name\\": \\"my-worker\\",
212-
\\"compatibility_date\\": \\"2000-01-01\\",
213-
\\"observability\\": {
214-
\\"enabled\\": true
213+
"$schema": "node_modules/wrangler/config-schema.json",
214+
"name": "my-worker",
215+
"compatibility_date": "2000-01-01",
216+
"observability": {
217+
"enabled": true
215218
},
216-
\\"assets\\": {
217-
\\"directory\\": \\"dist\\"
219+
"assets": {
220+
"directory": "dist"
218221
}
219222
}"
220223
`);
@@ -285,29 +288,29 @@ describe("autoconfig (deploy)", () => {
285288
286289
📄 Create wrangler.jsonc:
287290
{
288-
\\"$schema\\": \\"node_modules/wrangler/config-schema.json\\",
289-
\\"name\\": \\"edited-worker-name\\",
290-
\\"compatibility_date\\": \\"2000-01-01\\",
291-
\\"observability\\": {
292-
\\"enabled\\": true
291+
"$schema": "node_modules/wrangler/config-schema.json",
292+
"name": "edited-worker-name",
293+
"compatibility_date": "2000-01-01",
294+
"observability": {
295+
"enabled": true
293296
},
294-
\\"assets\\": {
295-
\\"directory\\": \\"dist\\"
297+
"assets": {
298+
"directory": "dist"
296299
}
297300
}
298301
"
299302
`);
300303

301304
expect(readFileSync("wrangler.jsonc")).toMatchInlineSnapshot(`
302305
"{
303-
\\"$schema\\": \\"node_modules/wrangler/config-schema.json\\",
304-
\\"name\\": \\"edited-worker-name\\",
305-
\\"compatibility_date\\": \\"2000-01-01\\",
306-
\\"observability\\": {
307-
\\"enabled\\": true
306+
"$schema": "node_modules/wrangler/config-schema.json",
307+
"name": "edited-worker-name",
308+
"compatibility_date": "2000-01-01",
309+
"observability": {
310+
"enabled": true
308311
},
309-
\\"assets\\": {
310-
\\"directory\\": \\"dist\\"
312+
"assets": {
313+
"directory": "dist"
311314
}
312315
}"
313316
`);

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe("wrangler setup", () => {
3535
-v, --version Show version number [boolean]
3636
3737
OPTIONS
38-
-y, --yes Answer \\"yes\\" to any prompts for configuring your project [boolean] [default: false]
38+
-y, --yes Answer "yes" to any prompts for configuring your project [boolean] [default: false]
3939
--build Run your project's build command once it has been configured [boolean] [default: false]
4040
--dry-run Runs the command without applying any filesystem modifications [boolean]"
4141
`);
@@ -168,14 +168,14 @@ describe("wrangler setup", () => {
168168
169169
📄 Create wrangler.jsonc:
170170
{
171-
\\"$schema\\": \\"node_modules/wrangler/config-schema.json\\",
172-
\\"name\\": \\"<WORKER_NAME>\\",
173-
\\"compatibility_date\\": \\"yyyy-mm-dd\\",
174-
\\"observability\\": {
175-
\\"enabled\\": true
171+
"$schema": "node_modules/wrangler/config-schema.json",
172+
"name": "<WORKER_NAME>",
173+
"compatibility_date": "yyyy-mm-dd",
174+
"observability": {
175+
"enabled": true
176176
},
177-
\\"assets\\": {
178-
\\"directory\\": \\"<DIR>\\"
177+
"assets": {
178+
"directory": "<DIR>"
179179
}
180180
}
181181

packages/wrangler/src/autoconfig/run.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export async function runAutoConfig(
3535
const runBuild = !dryRun && (autoConfigOptions.runBuild ?? true);
3636
const skipConfirmations =
3737
dryRun || autoConfigOptions.skipConfirmations === true;
38+
const enableWranglerInstallation =
39+
autoConfigOptions.enableWranglerInstallation ?? true;
3840

3941
const detected: AutoConfigMetrics = {
4042
buildCommand: autoConfigDetails.buildCommand,
@@ -107,7 +109,7 @@ export async function runAutoConfig(
107109
`Running autoconfig with:\n${JSON.stringify(autoConfigDetails, null, 2)}...`
108110
);
109111

110-
if (autoConfigSummary.wranglerInstall && autoConfigOptions.installWrangler) {
112+
if (autoConfigSummary.wranglerInstall && enableWranglerInstallation) {
111113
await installWrangler();
112114
}
113115

packages/wrangler/src/autoconfig/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export type AutoConfigOptions = {
3636
/**
3737
* Whether to install Wrangler during autoconfig
3838
*/
39-
installWrangler?: boolean;
39+
enableWranglerInstallation?: boolean;
4040
};
4141

4242
export type AutoConfigSummary = {

packages/wrangler/src/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const setupCommand = createCommand({
6060
runBuild: args.build,
6161
skipConfirmations: args.yes,
6262
dryRun: args.dryRun,
63-
installWrangler: args.installWrangler,
63+
enableWranglerInstallation: args.installWrangler,
6464
});
6565
if (!args.dryRun) {
6666
logCompletionMessage(

0 commit comments

Comments
 (0)