Enabled isolate: false for the ghost/core unit suite#28074
Conversation
WalkthroughThis PR restructures Ghost core's Vitest unit test execution into two separate projects: Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
The unit suite ran under vitest's default `isolate: true`, giving every test file a fresh module registry and cold-importing Ghost's heavy server modules ~550 times per run (~73s). It now runs under `isolate: false` — one shared registry per worker, the model mocha always used — which takes the suite to ~7s locally. - vitest.config.ts is split into two projects: `unit` (the bulk, isolate: false) and `unit-isolated` (6 files that still fail intermittently under a shared registry, kept on isolate: true until their root causes are fixed) - vitest-setup.ts's afterAll no longer destroys the knex pool per file — under a shared registry that breaks the pool for files scheduled after it; it drains in-flight queries instead. vitest-global-setup.ts removes the per-worker session sqlite files once per run - resolveSnapshotPath is set at the config root so vitest's native snapshot system stays away from the @tryghost/jest-snapshot `.snap` files — otherwise it adopts them and reports their entries as obsolete, which fails the run under CI - restores cache-invalidation.test.js, skipped pending this change (warm requires keep it well under the timeout)
47e19e2 to
1fef525
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 33e9a606-cd73-4301-8476-7103ce1aed9b
📒 Files selected for processing (4)
ghost/core/test/unit/api/cache-invalidation.test.jsghost/core/test/utils/vitest-global-setup.tsghost/core/test/utils/vitest-setup.tsghost/core/vitest.config.ts
The ghost/core unit suite ran under vitest's default
isolate: true— a fresh module registry per test file, cold-importing Ghost's heavy server modules ~550 times per run. It now runs underisolate: false(one shared registry per worker, the model mocha always used): ~73s → ~7s locally.How
vitest.config.tsis split into two projects:unit— the 546-file bulk,isolate: false.unit-isolated— 4 files that still fail intermittently under a shared registry, kept onisolate: trueuntil their root causes are fixed:create-migration,scheduling-default,public-config/config,taxonomy-router. The quarantine list is short on purpose — each entry is a known bug to fix, not a permanent home.Supporting changes for the shared registry:
vitest-setup.ts'safterAllno longer destroys the knex pool per file — under one shared pool per worker that would break every file scheduled after it. It now drains in-flight queries and leaves the pool for the worker to tear down.vitest-global-setup.tsremoves the per-worker session sqlite files once per run (previously done per-file).cache-invalidation.test.jsis un-skipped — it was skipped specifically pending this change; warm requires keep it well under the timeout.Jest→Vitest);isolate: falserewrites them on load, content unchanged.Verification
The
isolate: falsebulk project was stress-run 82 times locally (full suite, ~546 files) — 81 clean, 1 lone unrelated flake, well within the existing vitestretry: 2+ CI step-retry. Full suite (both projects) green at 550/550.🤖 Generated with Claude Code