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; constructor(options: IWorldOptions) { super(options); this.app = createApp(); this.agent = request.agent(this.app); } } setWorldConstructor(CustomWorld);