TIDE/frontend/blog_portal/cypress.config.ts

49 lines
1.4 KiB
TypeScript

import { defineConfig } from "cypress";
import { execSync } from "node:child_process";
import { resolve } from "node:path";
const backendDir = resolve(__dirname, "../../backend");
const mailpitBase = "http://localhost:8025/api/v1";
export default defineConfig({
e2e: {
baseUrl: "http://localhost:5173",
setupNodeEvents(on) {
on("task", {
"db:reset": function () {
execSync("php artisan migrate:fresh --force", {
cwd: backendDir,
stdio: "pipe",
});
return null;
},
"db:seed": function () {
execSync("php artisan db:seed --force", {
cwd: backendDir,
stdio: "pipe",
});
return null;
},
"db:promote": function (email: string) {
execSync(`php artisan user:promote ${JSON.stringify(email)}`, {
cwd: backendDir,
stdio: "pipe",
});
return null;
},
"mailpit:clear": async function () {
await fetch(`${mailpitBase}/messages`, { method: "DELETE" });
return null;
},
"mailpit:messages": async function () {
const response = await fetch(`${mailpitBase}/messages`);
return response.json();
},
"mailpit:message": async function (id: string) {
const response = await fetch(`${mailpitBase}/message/${id}`);
return response.json();
},
});
},
},
});