From c06a267db9f9c99d3db584e9717533fdf4acd906 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Thu, 17 Mar 2022 12:49:50 +0000 Subject: [PATCH] fix: do not warn about miniflare in the configuration --- .changeset/angry-items-serve.md | 5 +++++ .../src/__tests__/configuration.test.ts | 22 ++++++++++++++++++- packages/wrangler/src/config/validation.ts | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 .changeset/angry-items-serve.md diff --git a/.changeset/angry-items-serve.md b/.changeset/angry-items-serve.md new file mode 100644 index 000000000000..4598b22aa632 --- /dev/null +++ b/.changeset/angry-items-serve.md @@ -0,0 +1,5 @@ +--- +"wrangler": patch +--- + +fix: do not warn about miniflare in the configuration diff --git a/packages/wrangler/src/__tests__/configuration.test.ts b/packages/wrangler/src/__tests__/configuration.test.ts index adbb7f4c8d32..d90b58dcf817 100644 --- a/packages/wrangler/src/__tests__/configuration.test.ts +++ b/packages/wrangler/src/__tests__/configuration.test.ts @@ -129,6 +129,26 @@ describe("normalizeAndValidateConfig()", () => { }); it("should warn on and remove unexpected top level fields", () => { + const expectedConfig = { + unexpected: { + subkey: "some-value", + }, + }; + + const { config, diagnostics } = normalizeAndValidateConfig( + expectedConfig as unknown as RawConfig, + undefined + ); + + expect("unexpected" in config).toBe(false); + expect(diagnostics.hasErrors()).toBe(false); + expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(` + "Processing wrangler configuration: + - Unexpected fields found in top-level field: \\"unexpected\\"" + `); + }); + + it("should ignore `miniflare` top level fields", () => { const expectedConfig = { miniflare: { host: "127.0.0.1", @@ -144,7 +164,7 @@ describe("normalizeAndValidateConfig()", () => { expect(diagnostics.hasErrors()).toBe(false); expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(` "Processing wrangler configuration: - - Unexpected fields found in top-level field: \\"miniflare\\"" + " `); }); diff --git a/packages/wrangler/src/config/validation.ts b/packages/wrangler/src/config/validation.ts index d5e8a9b98822..477a32c15d55 100644 --- a/packages/wrangler/src/config/validation.ts +++ b/packages/wrangler/src/config/validation.ts @@ -151,7 +151,7 @@ export function normalizeAndValidateConfig( diagnostics, "top-level", Object.keys(rawConfig), - Object.keys(config) + [...Object.keys(config), "miniflare"] ); return { config, diagnostics };