Skip to content

Commit 9ca4049

Browse files
committed
Fix tests
1 parent caf68f8 commit 9ca4049

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
@@ -39,25 +39,25 @@ describe("autoconfig run - buildOperationsSummary()", () => {
3939
"
4040
📄 Create wrangler.jsonc:
4141
{
42-
\\"$schema\\": \\"node_modules/wrangler/config-schema.json\\",
43-
\\"name\\": \\"worker-name\\",
44-
\\"compatibility_date\\": \\"2025-01-01\\",
45-
\\"observability\\": {
46-
\\"enabled\\": true
42+
"$schema": "node_modules/wrangler/config-schema.json",
43+
"name": "worker-name",
44+
"compatibility_date": "2025-01-01",
45+
"observability": {
46+
"enabled": true
4747
}
4848
}
4949
"
5050
`);
5151

5252
expect(summary).toMatchInlineSnapshot(`
53-
Object {
53+
{
5454
"outputDir": "public",
55-
"scripts": Object {},
56-
"wranglerConfig": Object {
55+
"scripts": {},
56+
"wranglerConfig": {
5757
"$schema": "node_modules/wrangler/config-schema.json",
5858
"compatibility_date": "2025-01-01",
5959
"name": "worker-name",
60-
"observability": Object {
60+
"observability": {
6161
"enabled": true,
6262
},
6363
},
@@ -89,17 +89,17 @@ describe("autoconfig run - buildOperationsSummary()", () => {
8989
);
9090

9191
expect(summary).toMatchInlineSnapshot(`
92-
Object {
92+
{
9393
"outputDir": "dist",
94-
"scripts": Object {
94+
"scripts": {
9595
"deploy": "wrangler deploy",
9696
"preview": "wrangler dev",
9797
},
98-
"wranglerConfig": Object {
98+
"wranglerConfig": {
9999
"$schema": "node_modules/wrangler/config-schema.json",
100100
"compatibility_date": "2025-01-01",
101101
"name": "worker-name",
102-
"observability": Object {
102+
"observability": {
103103
"enabled": true,
104104
},
105105
},
@@ -133,17 +133,17 @@ describe("autoconfig run - buildOperationsSummary()", () => {
133133
);
134134

135135
expect(summary).toMatchInlineSnapshot(`
136-
Object {
136+
{
137137
"outputDir": "out",
138-
"scripts": Object {
138+
"scripts": {
139139
"deploy": "wrangler deploy",
140140
"preview": "wrangler dev",
141141
},
142-
"wranglerConfig": Object {
142+
"wranglerConfig": {
143143
"$schema": "node_modules/wrangler/config-schema.json",
144144
"compatibility_date": "2025-01-01",
145145
"name": "worker-name",
146-
"observability": Object {
146+
"observability": {
147147
"enabled": true,
148148
},
149149
},

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,
@@ -110,7 +112,7 @@ export async function runAutoConfig(
110112
`Running autoconfig with:\n${JSON.stringify(autoConfigDetails, null, 2)}...`
111113
);
112114

113-
if (autoConfigSummary.wranglerInstall && autoConfigOptions.installWrangler) {
115+
if (autoConfigSummary.wranglerInstall && enableWranglerInstallation) {
114116
await installWrangler();
115117
}
116118

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)