Removed unused session-sqlite plumbing from vitest setup#28115
Conversation
- vitest-setup.ts wired a per-worker session sqlite path, a random server port, and a URL env override before booting Ghost - nothing in the unit suite opens the default knex pool or starts a server; running the full 6585-test suite produces zero /tmp/ghost-test-*.db files - the snapshot port-normalization block existed only because the port was randomized; Ghost's testing config already defaults to 2369 (the canonical port committed in snapshots), so removing the random port makes the normalization dead code - the afterAll knex pool drain was guarding against a pool that no test connects, also dead - vitest-global-setup.ts only existed to clean up sqlite files that never got created; deleted, and the globalSetup entry removed from vitest.config.ts
WalkthroughThis PR refactors Ghost's Vitest test lifecycle by removing the global setup teardown mechanism and simplifying per-test initialization. The Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run ghost:test:ci:integration |
✅ Succeeded | 2m | View ↗ |
nx run ghost:test:ci:e2e |
✅ Succeeded | 7m 37s | View ↗ |
nx run ghost:test:ci:legacy |
✅ Succeeded | 3m 1s | View ↗ |
nx run-many -t lint -p ghost |
✅ Succeeded | 38s | View ↗ |
nx run-many -t test:unit -p ghost |
✅ Succeeded | 29s | View ↗ |
☁️ Nx Cloud last updated this comment at 2026-05-25 19:59:50 UTC
ref #28115 Shared Vitest config changes can affect more tests than Nx marks as changed, so CI now widens unit-test project selection for root config changes while keeping Ghost core config changes scoped to Ghost core.

The
ghost/coreunit suite'svitest-setup.tswired a per-worker session sqlite path, a random server port, and a URL env override before booting Ghost. This existed as a safety net for unit tests that opened the default knex pool or spun up a server — but nothing in the suite actually does either of those things. Running the full 6585-test suite produces zero/tmp/ghost-test-*.dbfiles. The plumbing has no observable effect today and is a maintenance assumption to remember.Removed in this PR:
sessionId/database__connection__*/server__port/urlenv block at the top ofvitest-setup.tsconfig.testing.json) already defaults to2369, which matches the canonical port committed in snapshots, so once the random port is gone the normalization is dead codeafterAllknex-pool-drain loop — guards against a pool that no unit test connectsvitest-global-setup.ts— only existed to clean up sqlite files that never got created. File deleted,globalSetupentry removed fromvitest.config.tsVerification: full
pnpm test:vitestrun is green (550 files / 6575 tests passed, 7.57s, within noise of pre-PR), and/tmp/ghost-test-*.dbstays empty across the run.