fix(test/server): dayjs initialization issue

This commit is contained in:
Elian Doran 2025-05-17 09:45:53 +03:00
parent a3a1667351
commit a5952b76d2
No known key found for this signature in database
2 changed files with 6 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import { beforeAll } from "vitest";
import i18next from "i18next";
import { join } from "path";
import dayjs from "dayjs";
beforeAll(async () => {
// Initialize the translations manually to avoid any side effects.
@ -15,4 +16,8 @@ beforeAll(async () => {
loadPath: join(__dirname, "../src/assets/translations/{{lng}}/{{ns}}.json")
}
});
// Initialize dayjs
await import("dayjs/locale/en.js");
dayjs.locale("en");
});

View File

@ -36,11 +36,11 @@ export async function initializeTranslations() {
} catch (err) {
console.warn(`Could not load locale ${dayjsLocale}`, err);
}
dayjs.locale(dayjsLocale);
}
export function ordinal(date: Dayjs) {
return dayjs(date)
.locale(dayjsLocale)
.format("Do");
}