perf(test): optimize super-editor test environment#2495
Closed
caio-pizzol wants to merge 10 commits intomainfrom
Closed
perf(test): optimize super-editor test environment#2495caio-pizzol wants to merge 10 commits intomainfrom
caio-pizzol wants to merge 10 commits intomainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c2350d1e57
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
packages/super-editor/src/core/commands/restartNumbering.test.js
Outdated
Show resolved
Hide resolved
packages/super-editor/src/core/super-converter/SuperConverter.test.js
Outdated
Show resolved
Hide resolved
Add automated migration script and apply it to super-converter.
Apply migration script to all super-editor test directories. 674 files migrated, 180 skipped (DOM-dependent), 8 skipped (unsupported). Migration patterns applied: - vi.fn → mock, vi.spyOn → spyOn, vi.mock → mock.module - vi.hoisted unwrapped via paren-matching - vi.stubGlobal → globalThis assignment - Static imports converted to dynamic for mock.module files - Timer APIs mapped to jest.* equivalents from bun:test Pure tests (no mock.module) pass at ~99%. Mock.module files need further tuning as bun's module mocking behaves differently from vitest's hoisted vi.mock.
- Fix mock.module(import('path')) → mock.module('path') (4 files)
- Restore uuidv4.mockClear() in SuperConverter test for isolation
- Add EditorConstructor.mockClear() in SuperInput beforeEach
Vitest can't resolve bun:test imports. Generate a list of 674 migrated files and exclude them from vitest config. These files run under bun test separately.
5aa559b to
16223de
Compare
Add test:bun script to super-editor that runs migrated files per directory (bun crashes with 674+ files at once). Hook it into the root test script so CI runs all tests — both vitest and bun.
Replace bun-test-files.txt with a grep at vitest config time that finds files importing from bun:test. No manual list to maintain — new test files are automatically routed to the correct runner.
Revert bun:test imports back to vitest. The mock.module() behavior differences cause ~400 test failures under bun, and some directories hang indefinitely. Until bun's module mocking matures or we rewrite the mock patterns, super-editor tests stay on vitest. The migration script and validated patterns are preserved in git history for when we're ready to resume.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Switch ~484 pure-logic super-editor tests from happy-dom to node environment, reducing unnecessary browser simulation overhead.
What changed
Added
environmentMatchGlobsto the super-editor vitest config. Tests in directories that don't use DOM (converters, commands, helpers, parts, document-api adapters, utils) now run in node environment instead of happy-dom. Files that need DOM are explicitly kept on happy-dom.What we tried but reverted
We attempted a full migration of 674 super-editor test files to bun:test. Pure tests (no mocking) passed at ~99%, but ~188 files using
vi.mock()failed because bun handles module mocking differently — it doesn't hoist mocks before imports the way vitest does. Some directories also caused bun to hang. We reverted the migration to keep all tests green in CI.The migration patterns and script are preserved in git history for future use when bun's module mocking matures.
Test plan