Coexists with Mocha (kept for unit-style tests) and Cypress (unchanged, web e2e). Adds: - apps/api/features/*.feature — Gherkin scenarios - apps/api/features/step-definitions/*.steps.ts — step implementations - apps/api/features/support/world.ts — per-scenario World, spins up the Express app in-process via createApp() + supertest (no real server needed, same approach as the existing Mocha health test) - apps/api/cucumber.cjs — config, deliberately .cjs (not .js) to avoid the same ESM/CJS config-loading mismatch that broke apps/web/cypress.config.ts earlier - `test:bdd` script (cross-env + tsx via NODE_OPTIONS=--import=tsx, for cross-platform ESM+TS loading) - health.feature/steps as a working example, mirroring the existing Mocha health test so both suites cover the same behavior in their respective styles CI: runs `pnpm --filter api test:bdd` alongside the existing test step. README: documents the new test layer and the TS/ESM config-loading caveat for future tool configs. Verified locally: lint, mocha, cucumber, and full build all pass.
18 lines
582 B
TypeScript
18 lines
582 B
TypeScript
import { type IWorldOptions, World, setWorldConstructor } from "@cucumber/cucumber";
|
|
import type { Express } from "express";
|
|
import type 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.
|
|
export class CustomWorld extends World {
|
|
app: Express;
|
|
response!: request.Response;
|
|
|
|
constructor(options: IWorldOptions) {
|
|
super(options);
|
|
this.app = createApp();
|
|
}
|
|
}
|
|
|
|
setWorldConstructor(CustomWorld);
|