Spaces:
Sleeping
Sleeping
File size: 919 Bytes
05c5ed5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import { execSync } from "child_process";
import { getUserCount } from "../helpers/clear-users";
async function globalSetup() {
// Skip seeding if we're running first-user tests
if (process.env.SKIP_SEEDING === "true") {
console.log("⏭️ Skipping user seeding for first-user tests");
return;
}
console.log("\n🌱 Global Setup: Checking if users need to be seeded...");
const userCount = await getUserCount();
console.log(`📊 Current user count: ${userCount}`);
if (userCount < 3) {
console.log("⚠️ Not enough test users, running seed script...");
try {
execSync("pnpm test:e2e:seed", { stdio: "inherit" });
console.log("✅ Test users seeded successfully");
} catch (error) {
console.error("❌ Failed to seed test users:", error);
throw error;
}
} else {
console.log("✅ Test users already exist");
}
}
export default globalSetup;
|