Skip to content
Draft

Refactor #13845

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions packages/wrangler/src/__tests__/deploy/core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,23 +533,6 @@ describe("deploy", () => {
`);
});

it("should error helpfully if pages_build_output_dir is set in wrangler.toml when --x-autoconfig=false", async ({
expect,
}) => {
writeWranglerConfig({
pages_build_output_dir: "public",
name: "test-name",
});
await expect(
runWrangler("deploy --x-autoconfig=false")
).rejects.toThrowErrorMatchingInlineSnapshot(
`
[Error: It looks like you've run a Workers-specific command in a Pages project.
For Pages, please run \`wrangler pages deploy\` instead.]
`
);
});

it("should error helpfully if pages_build_output_dir is set in wrangler.toml and --x-autoconfig is provided", async ({
expect,
}) => {
Expand Down Expand Up @@ -1146,6 +1129,16 @@ describe("deploy", () => {
expect(std.warn).toMatchInlineSnapshot(`""`);
});

describe("legacy", () => {
it("uses the script name when no environment is specified", async ({
expect,
}) => {
writeWranglerConfig();
writeWorkerSource();
mockSubDomainRequest();
mockUploadWorkerRequest({
useServiceEnvironments: false,
});
Comment on lines +1132 to +1141
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block (lines 1132-1141) is an incomplete duplicate of the describe("legacy") block that immediately follows it at line 1142. It opens a describe and it callback, sets up mocks, but never closes any braces or calls runWrangler. This will either cause a syntax error or produce a broken nested test structure.

Suggested change
describe("legacy", () => {
it("uses the script name when no environment is specified", async ({
expect,
}) => {
writeWranglerConfig();
writeWorkerSource();
mockSubDomainRequest();
mockUploadWorkerRequest({
useServiceEnvironments: false,
});

describe("legacy", () => {
it("uses the script name when no environment is specified", async ({
expect,
Expand Down
20 changes: 10 additions & 10 deletions packages/wrangler/src/__tests__/deploy/workers-dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -781,11 +781,11 @@ describe("deploy", () => {

expect(err?.message.replaceAll(/\d/g, "X")).toMatchInlineSnapshot(`
"A compatibility_date is required when publishing. Add the following to your Wrangler configuration file:
\`\`\`
{"compatibility_date":"XXXX-XX-XX"}
\`\`\`
Or you could pass it in your terminal as \`--compatibility-date XXXX-XX-XX\`
See https://developers.cloudflare.com/workers/platform/compatibility-dates for more information."
\`\`\`
{"compatibility_date":"XXXX-XX-XX"}
\`\`\`
Or you could pass it in your terminal as \`--compatibility-date XXXX-XX-XX\`
See https://developers.cloudflare.com/workers/platform/compatibility-dates for more information."
`);
});

Expand All @@ -801,11 +801,11 @@ describe("deploy", () => {
async () => await runWrangler("deploy ./index.js --name my-worker")
).rejects.toThrowErrorMatchingInlineSnapshot(`
[Error: A compatibility_date is required when publishing. Add the following to your Wrangler configuration file:
\`\`\`
{"compatibility_date":"2020-12-01"}
\`\`\`
Or you could pass it in your terminal as \`--compatibility-date 2020-12-01\`
See https://developers.cloudflare.com/workers/platform/compatibility-dates for more information.]
\`\`\`
{"compatibility_date":"2020-12-01"}
\`\`\`
Or you could pass it in your terminal as \`--compatibility-date 2020-12-01\`
See https://developers.cloudflare.com/workers/platform/compatibility-dates for more information.]
`);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ describe("versions upload", () => {
writeWorkerSource();

await expect(runWrangler("versions upload --dry-run")).rejects.toThrow(
/A compatibility_date is required when uploading a Worker Version/
/compatibility_date is required when publishing/
);
});

Expand Down
Loading
Loading