Skip to content

Commit 48b73e0

Browse files
fix up test snapshots for Windows
1 parent a54d88c commit 48b73e0

File tree

1 file changed

+58
-24
lines changed

1 file changed

+58
-24
lines changed

packages/wrangler/src/__tests__/config/findWranglerConfig.test.ts

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from "node:path";
22
import { findWranglerConfig } from "../../config/config-helpers";
33
import { mockConsoleMethods } from "../helpers/mock-console";
4+
import { normalizeString } from "../helpers/normalize";
45
import { runInTempDir } from "../helpers/run-in-tmp";
56
import { seed } from "../helpers/seed";
67

@@ -163,26 +164,37 @@ describe("config findWranglerConfig()", () => {
163164
await seed({
164165
[".wrangler/deploy/config.json"]: `INVALID JSON`,
165166
});
166-
expect(() =>
167-
findWranglerConfig(".", { useRedirect: true })
168-
).toThrowErrorMatchingInlineSnapshot(
169-
`[Error: Failed to load the deploy config at .wrangler/deploy/config.json]`
170-
);
167+
168+
let error;
169+
try {
170+
findWranglerConfig(".", { useRedirect: true });
171+
} catch (e) {
172+
error = e;
173+
}
174+
175+
expect(normalizeString(`${error}`)).toMatchInlineSnapshot(`"Error: Failed to load the deploy config at .wrangler/deploy/config.json"`);
171176
expect(std).toEqual(NO_LOGS);
172177
});
173178

174179
it("should error if deploy config does not contain a `configPath` property", async () => {
175180
await seed({
176181
[".wrangler/deploy/config.json"]: `{}`,
177182
});
178-
expect(() => findWranglerConfig(".", { useRedirect: true }))
179-
.toThrowErrorMatchingInlineSnapshot(`
180-
[Error: A redirect config was found at ".wrangler/deploy/config.json".
181-
But this is not valid - the required "configPath" property was not found.
183+
184+
let error;
185+
try {
186+
findWranglerConfig(".", { useRedirect: true });
187+
} catch (e) {
188+
error = e;
189+
}
190+
191+
expect(normalizeString(`${error}`)).toMatchInlineSnapshot(`
192+
"Error: A redirect config was found at \\".wrangler/deploy/config.json\\".
193+
But this is not valid - the required \\"configPath\\" property was not found.
182194
Instead this file contains:
183195
\`\`\`
184196
{}
185-
\`\`\`]
197+
\`\`\`"
186198
`);
187199
expect(std).toEqual(NO_LOGS);
188200
});
@@ -191,10 +203,17 @@ describe("config findWranglerConfig()", () => {
191203
await seed({
192204
[".wrangler/deploy/config.json"]: `{ "configPath": "missing/wrangler.json" }`,
193205
});
194-
expect(() => findWranglerConfig(".", { useRedirect: true }))
195-
.toThrowErrorMatchingInlineSnapshot(`
196-
[Error: There is a redirect configuration at ".wrangler/deploy/config.json".
197-
But the config path it points to, ".wrangler/deploy/missing/wrangler.json", does not exist.]
206+
207+
let error;
208+
try {
209+
findWranglerConfig(".", { useRedirect: true });
210+
} catch (e) {
211+
error = e;
212+
}
213+
214+
expect(normalizeString(`${error}`)).toMatchInlineSnapshot(`
215+
"Error: There is a redirect configuration at \\".wrangler/deploy/config.json\\".
216+
But the config path it points to, \\".wrangler/deploy/missing/wrangler.json\\", does not exist."
198217
`);
199218
expect(std).toEqual(NO_LOGS);
200219
});
@@ -209,17 +228,32 @@ describe("config findWranglerConfig()", () => {
209228
["bar/.wrangler/deploy/config.json"]: `{ "configPath": "../../dist/wrangler.json" }`,
210229
[`bar/dist/wrangler.json`]: "DUMMY",
211230
});
212-
expect(() => findWranglerConfig("foo/bar", { useRedirect: true }))
213-
.toThrowErrorMatchingInlineSnapshot(`
214-
[Error: Found both a user config file at "foo/wrangler.toml"
215-
and a redirect config file at "foo/bar/.wrangler/deploy/config.json".
216-
But these do not share the same base path so it is not clear which should be used.]
231+
232+
let error;
233+
try {
234+
findWranglerConfig("foo/bar", { useRedirect: true });
235+
} catch (e) {
236+
error = e;
237+
}
238+
239+
expect(normalizeString(`${error}`)).toMatchInlineSnapshot(`
240+
"Error: Found both a user config file at \\"foo/wrangler.toml\\"
241+
and a redirect config file at \\"foo/bar/.wrangler/deploy/config.json\\".
242+
But these do not share the same base path so it is not clear which should be used."
217243
`);
218-
expect(() => findWranglerConfig("bar/foo", { useRedirect: true }))
219-
.toThrowErrorMatchingInlineSnapshot(`
220-
[Error: Found both a user config file at "bar/foo/wrangler.toml"
221-
and a redirect config file at "bar/.wrangler/deploy/config.json".
222-
But these do not share the same base path so it is not clear which should be used.]
244+
expect(std).toEqual(NO_LOGS);
245+
246+
try {
247+
error = undefined;
248+
findWranglerConfig("bar/foo", { useRedirect: true });
249+
} catch (e) {
250+
error = e;
251+
}
252+
253+
expect(normalizeString(`${error}`)).toMatchInlineSnapshot(`
254+
"Error: Found both a user config file at \\"bar/foo/wrangler.toml\\"
255+
and a redirect config file at \\"bar/.wrangler/deploy/config.json\\".
256+
But these do not share the same base path so it is not clear which should be used."
223257
`);
224258
expect(std).toEqual(NO_LOGS);
225259
});

0 commit comments

Comments
 (0)