Migrated test/unit/api bucket to vitest#27991
Conversation
- continues the vitest migration (after #27898 / #27900 / #27974) by moving all 33 files in test/unit/api (280 tests) from mocha to vitest - mocha-isms converted: members.test.js before() -> beforeAll(); four this.timeout() calls in serializers/input/{pages,posts}.test.js -> the it(name, {timeout}, fn) options form - validators/input/{pages,posts}.test.js: the beforeEach stubbed Member.findPage with .returns(Promise.reject()), which eagerly creates a rejected promise at setup time. When a test never calls the stub, that promise is never consumed and surfaces as an unhandled rejection (60 of them under vitest, which fails the run; mocha silently ignored them). Switched to sinon's lazy .rejects()/.resolves() so the promise is only created when the stub is actually called - added test/unit/api to vitest.config.ts include; removed it from test:unit:base so vitest is the sole runner
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
WalkthroughThis PR migrates the Possibly related PRs
Suggested reviewers
🚥 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 |
no ref Final big bucket of the vitest migration (after #27898 / #27900 / #27974 / #27991 / #27992 / #27996) — moves `test/unit/server/services` (256 files, ~3290 tests) from mocha to vitest. It also fixes a **vitest worker-teardown bug** that this DB-heavy bucket exposed (the previous buckets happened not to trigger it).
Summary
Continues the vitest migration (after #27898 / #27900 / #27974) by moving the
test/unit/apibucket — 33 files, 280 tests — from mocha to vitest.What's changed
vitest.config.ts— addedtest/unit/api/**totest.includepackage.json— removed./test/unit/apifromtest:unit:baseso vitest is the sole runnermembers.test.js—before()→beforeAll()serializers/input/pages.test.js+serializers/input/posts.test.js— fourthis.timeout(N)calls → theit(name, {timeout: N}, fn)options formvalidators/input/pages.test.js+validators/input/posts.test.js— see belowUnhandled-rejection fix
validators/input/{pages,posts}.test.jshad abeforeEachthat stubbedMember.findPagewith.returns(Promise.reject()). That eagerly creates a rejected promise at stub-setup time. When a test never exercises the stub, the promise is never consumed and Node flags it as an unhandled rejection — 60 of them across the two files ({ type: 'Unhandled Rejection', message: undefined }). Mocha silently ignored these; vitest surfaces them and fails the run.Fix: switched to sinon's lazy
.rejects()/.resolves(), which only create the promise when the stub is actually called.Test plan
pnpm test:vitest test/unit/api(fromghost/core): 33 files / 280 tests pass, zero unhandled rejectionspnpm test:unit:base(mocha): 5386 tests passpnpm exec eslintclean for changed files