Skip to content

Commit 571065c

Browse files
committed
vi.stubEnv
1 parent a6bc4cd commit 571065c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/util.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { beforeEach, describe, expect, test } from "vitest";
1+
import { afterEach } from "node:test";
2+
import { beforeEach, describe, expect, test, vi } from "vitest";
23
import { delay } from "es-toolkit";
34
import {
45
addDays,
@@ -40,6 +41,15 @@ describe("enarray", () => {
4041
});
4142

4243
describe("formatDate", () => {
44+
// Ensure the test runs in a known timezone
45+
beforeEach(() => {
46+
vi.stubEnv("TZ", "UTC+1");
47+
});
48+
49+
afterEach(() => {
50+
vi.unstubAllEnvs();
51+
});
52+
4353
test("formats a date", () => {
4454
// Date in UTC in winter
4555
const dateStrWinter = "2022-11-30T12:44:37Z";

0 commit comments

Comments
 (0)