import { type IWorldOptions, World, setWorldConstructor } from "@cucumber/cucumber"; import type { Express } from "express"; import request from "supertest"; import { createApp } from "../../src/app.js"; // Fresh Express app per scenario (in-process, via supertest — no server to // spin up/tear down) plus the last HTTP response, available to every step. // `agent` persists cookies across requests within a scenario (needed for // "sign up then check I'm authenticated" style flows). export class CustomWorld extends World { app: Express; agent: ReturnType; response!: request.Response; /** A second, independent session (own cookie jar) — only used by scenarios needing two distinct signed-in users, e.g. household invites/admin transfer/member removal. */ secondAgent: ReturnType; secondResponse!: request.Response; constructor(options: IWorldOptions) { super(options); this.app = createApp(); this.agent = request.agent(this.app); this.secondAgent = request.agent(this.app); } } setWorldConstructor(CustomWorld);