E2E Fixer
E2E is the default test tier here (*.e2e-spec.ts, real Nest app + supertest + SQLite). Most "failures"
are environment/isolation, not logic — separate the two before editing source.
First: is it mine, pre-existing, or flaky?
- Run the failing suite in isolation:
corepack yarn vitest run --project e2e-packages "<suite-path>". Passes alone but fails in the full run → see the known rotating-404 flake in CHANGELOG.md before digging. - Establish a baseline with
git stash(keep node_modules) and re-run the suite. Same failure on clean HEAD → pre-existing, not your regression. Say so explicitly; do not "fix" pre-existing breakage silently.
Known failure classes and fixes
- Rotating full-run failures = host memory pressure, not a code bug. Symptoms vary (unexpected 404, an
expected 401 arriving as 404,
Parse Error: Expected HTTP/) with a different victim suite each run. Tell: the failing run takes ~20x longer than a passing one (216s vs 10.8s) and the real failures are 30s timeouts with no HTTP response. Check free RAM / pageouts before touching any test. Diagnosis and evidence in CHANGELOG.md "Intermittent e2e failures". Fix the host (--maxWorkers=2, free memory) — never retry-loop, skip, or weaken assertions. - Barrel registration collisions. Importing a
domains/*/indexbarrel registers@CommandHandler/@QueryHandlerin global Reflect metadata and breaks later Nest apps in the same process. Never import a barrel in an e2e file that boots an app. (The barrel-last sequencer is gone; no barrel-only specs exist.) - Teardown / open handles. A hanging suite process +
Parse Error: Expected HTTP/from supertest = an app wasn't closed. Ensureawait app.close()inafterEach/afterAll.forceExitis off on purpose — a leak hangs and gets reported instead of being masked. - Fixture drift (v7→v8). Symptoms: 500s,
Class extends value undefined,x is not a function. Fix the fixture to the v8 pattern —RepositoryModule.forFeaturefor every entity, no duplicateTypeOrmModule.forRoot, correctextras(user/otp/role/federated/invitation). Reusepackages/rockets-server-auth/src/__fixtures__/and__e2e__/helpers/. - Module-resolution after a bump.
Cannot find module '@concepta/.../subpath'→ see upstream-migrator. Vitest resolves the packageexportsmaps natively; if a subpath fails, the exports map itself is wrong.
Rules
- New tests must be
*.e2e-spec.tsunless a unit test is specifically justified. Coverage target ≥ 80% viayarn test:e2e:cov. - Fix the test setup or the real bug — never weaken an assertion or add
anyto make red go green. - Report the final tally honestly (passed/failed/skipped) and label each remaining failure as fixed, pre-existing, or flaky.