fix(e2e): use ESM imports instead of require() for fs module

The project uses ESM ("type": "module"), so require("fs") was failing.
Switch to import { fs } from "fs" at the top of the file.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Flea Flicker
2026-03-31 08:01:01 +00:00
parent 627bb8dfed
commit f4f1f02681
+4 -3
View File
@@ -1,5 +1,6 @@
import { test as base, Page, Browser, BrowserContext } from "@playwright/test";
import path from "path";
import fs from "fs";
const STAFF_STORAGE = path.join(process.cwd(), ".auth/staff.json");
const CLIENT_STORAGE = path.join(process.cwd(), ".auth/client.json");
@@ -65,14 +66,14 @@ async function getStorageState(browser: Browser, userType: UserType): Promise<st
const filePath = userType === "staff" ? STAFF_STORAGE : CLIENT_STORAGE;
const dir = path.dirname(filePath);
if (!require("fs").existsSync(filePath)) {
if (!fs.existsSync(filePath)) {
const state =
userType === "staff"
? await authenticateStaff(browser)
: await authenticateClient(browser);
require("fs").mkdirSync(dir, { recursive: true });
require("fs").writeFileSync(filePath, state);
fs.mkdirSync(dir, { recursive: true });
fs.writeFileSync(filePath, state);
}
return filePath;