Skip to content

Commit 17e2729

Browse files
committed
fixup! tests
1 parent 47f8bef commit 17e2729

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5353,6 +5353,14 @@ addEventListener('fetch', event => {});`
53535353
});
53545354

53555355
describe("workers_dev setting", () => {
5356+
beforeEach(() => {
5357+
vi.useFakeTimers();
5358+
});
5359+
5360+
afterEach(() => {
5361+
vi.useRealTimers();
5362+
});
5363+
53565364
it("should deploy to a workers.dev domain if workers_dev is undefined", async () => {
53575365
writeWranglerConfig();
53585366
writeWorkerSource();
@@ -5788,26 +5796,20 @@ addEventListener('fetch', event => {});`
57885796
`);
57895797
});
57905798

5791-
it("should error if a compatibility_date is missing and suggest the correct month", async () => {
5792-
vi.spyOn(Date.prototype, "getMonth").mockImplementation(() => 11);
5793-
vi.spyOn(Date.prototype, "getFullYear").mockImplementation(() => 2020);
5794-
vi.spyOn(Date.prototype, "getDate").mockImplementation(() => 1);
5799+
it("should error if a compatibility_date is missing and suggest the correct date", async () => {
5800+
vi.setSystemTime(new Date(2020, 11, 1));
57955801

57965802
writeWorkerSource();
5797-
let err: undefined | Error;
5798-
try {
5799-
await runWrangler("deploy ./index.js --name my-worker");
5800-
} catch (e) {
5801-
err = e as Error;
5802-
}
58035803

5804-
expect(err?.message).toMatchInlineSnapshot(`
5805-
"A compatibility_date is required when publishing. Add the following to your Wrangler configuration file:
5804+
await expect(
5805+
async () => await runWrangler("deploy ./index.js --name my-worker")
5806+
).rejects.toThrowErrorMatchingInlineSnapshot(`
5807+
[Error: A compatibility_date is required when publishing. Add the following to your Wrangler configuration file:
58065808
\`\`\`
5807-
{\\"compatibility_date\\":\\"2020-12-01\\"}
5809+
{"compatibility_date":"2020-12-01"}
58085810
\`\`\`
58095811
Or you could pass it in your terminal as \`--compatibility-date 2020-12-01\`
5810-
See https://developers.cloudflare.com/workers/platform/compatibility-dates for more information."
5812+
See https://developers.cloudflare.com/workers/platform/compatibility-dates for more information.]
58115813
`);
58125814
});
58135815

0 commit comments

Comments
 (0)