diff --git a/apps/web/cypress/support/step_definitions/common.steps.ts b/apps/web/cypress/support/step_definitions/common.steps.ts index 10e38bd..b428189 100644 --- a/apps/web/cypress/support/step_definitions/common.steps.ts +++ b/apps/web/cypress/support/step_definitions/common.steps.ts @@ -1,4 +1,4 @@ -import { Before, Given, Then, When } from "@badeball/cypress-cucumber-preprocessor"; +import { Given, Then, When } from "@badeball/cypress-cucumber-preprocessor"; import { buildProfile, currentProfile, resetProfile, setCurrentProfile } from "../profile"; // Steps shared across every feature — signing in/out, navigation, and @@ -13,15 +13,22 @@ import { buildProfile, currentProfile, resetProfile, setCurrentProfile } from ". // (see .github/workflows/ci.yml); apps/api's own Mocha/Cucumber suites // cover real API behavior against a real database. -Before(() => { - resetProfile(); -}); - Given("I am not signed in", () => { cy.intercept("GET", "**/auth/me", { statusCode: 401 }); }); +// No `Before()` hook for this reset (deliberately) — registering any +// Cucumber hook makes the preprocessor's browser runtime read +// `messages.HookType.{BEFORE,AFTER}_TEST_CASE` to report it, and that enum +// doesn't exist on the older, CommonJS-only `@cucumber/messages` this repo +// is pinned to (see `pnpm.overrides` in package.json, and this branch's +// commit history for why) — every scenario crashed on "Cannot read +// properties of undefined (reading 'BEFORE_TEST_CASE')" the moment this +// file registered one. Resetting right here instead, at the one step every +// profile-building chain always starts with, is equivalent for our +// purposes without needing a hook at all. Given("I am signed in as {string} {string}", (firstName: string, lastName: string) => { + resetProfile(); setCurrentProfile( buildProfile({ firstName,