fix(core): add editor cleanup in BlockNoteEditor.test.ts#2816
Conversation
…nhandled DOMObserver errors Tests that mount editors were not calling unmount() afterward, leaving ProseMirror's DOMObserver timers active. When prosemirror-view is updated to newer versions (e.g. 1.41.8 via fresh dep resolution), a dangling setTimeout in DOMObserver.flush() fires after jsdom teardown, causing 'document is not defined' ReferenceError. Add afterEach cleanup following the same pattern as transformPasted.test.ts.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe test file now implements centralized cleanup for created ChangesBlockNoteEditor Test Cleanup
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~4 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 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)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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 |
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/mantine
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
commit: |
Problem
The Fresh Install Tests CI workflow fails at the "Run unit tests" step with:
All 28 test files pass individually (449 tests), but Vitest catches 1 unhandled error originating from
BlockNoteEditor.test.ts.Root Cause
Two tests (
sets an initial block id when using Y.jsandonBeforeChange) calleditor.mount()to create a ProseMirrorEditorViewbut never calleditor.unmount(). This leaves ProseMirror'sDOMObserveractive with a 20mssetTimeoutthat fires after jsdom is torn down, causing thedocument is not definederror.When
pnpm update --prodbumpsprosemirror-viewto1.41.8, timing changes make this latent bug surface.Fix
Add an
afterEachcleanup hook that callseditor.unmount()on all editors created during each test, following the same pattern already used intransformPasted.test.ts. This ensuresEditorView.destroy()is called, which setsdocView = nullso any lingering DOMObserver timers bail out harmlessly.Testing
vitest run src/editor/BlockNoteEditor.test.ts— 8/8 tests pass, 0 unhandled errorsSummary by CodeRabbit