Repository navigation
[tests] Chore: silence unnecessary stderr warnings in test-unit - #9098
Merged
etrepum merged 3 commits intoAug 25, 2026
Merged
Conversation
…derr warnings in test-unit ## Description `pnpm run test-unit` passes, but the default reporter shows 16 stderr blocks of DEV-mode warnings that are all either missing test configuration or expected warnings from deliberately-exercised anti-patterns. This change makes the unit test run warning-free without changing any library behavior: - **lexical-table**: `TableNode: hasHorizontalScroll is active but theme.tableScrollableWrapper is not defined.` — configure a theme with `tableScrollableWrapper` on the test extensions in `LexicalTableObserver.test.ts`, `FormatElementTableRect.test.ts`, `ToggleHeaderStyle.test.ts`, and the deprecated-alias test in `TableImportExtension.test.ts`, matching the other table tests. - **lexical** `LexicalEditor.test.tsx`: the two node-replacement tests that deliberately pass `replace` without `withKlass` now spy on `console.warn` and assert the deprecation warning, following the existing pattern used elsewhere in the same file. - **lexical** `LexicalNode.test.ts`: the `restoreSelection=false` cross-parent move tests intentionally leave a stale element offset past the parent's new child count, so reconciliation's `setBaseAndExtent` throws an `IndexSizeError` that the reconciler catches and warns about (`DOMException` on stderr). Spy on `console.warn` and assert the expected `DOMException`. - **lexical-react**: `An update to EditorComponent inside a test was not wrapped in act(...)` — tests that build an editor with `using` and render it through `LexicalExtensionEditorComposer` now unmount the React root inside `act()` before the end of the test, so end-of-scope `editor.dispose()` no longer updates a still-mounted component outside of act (`LexicalExtensionEditorComposer.test.tsx`, `useExtensionSignalValue.test.tsx`). - **lexical-react** `LexicalExtensionComposer.test.tsx`: the Firefox focus-bug reproduction calls `setRootElement` inside `editor.update()`, which makes the AutoFocus root listener call `editor.focus()` with a read-only context on the stack; `updateEditorSync` warns about that anti-pattern in DEV. Spy on `console.warn` and assert the warning, matching the existing read-only-context test in `LexicalEditor.test.tsx`. ## Test plan ### Before `pnpm run test-unit` (verbose reporter) shows 16 stderr blocks, e.g.: ``` stderr | packages/lexical-table/src/__tests__/unit/LexicalTableObserver.test.ts > TableObserver tracking MutationObserver teardown (meta#9073) > does not fire the tracking MutationObserver for mutations of the detached table after editor teardown TableNode: hasHorizontalScroll is active but theme.tableScrollableWrapper is not defined. stderr | packages/lexical/src/__tests__/unit/LexicalEditor.test.tsx > LexicalEditor tests > node replacement > applies the replacement on import for `with` without `withKlass` Override for ParagraphNode specifies 'replace' without 'withKlass'. 'withKlass' will be required in a future version. stderr | packages/lexical/src/__tests__/unit/LexicalNode.test.ts > Element-anchored selection on old parent (meta#6031) > cross-parent move > 'insertBefore' with restoreSelection=false skips the source-parent shift DOMException {} stderr | packages/lexical-react/src/__tests__/unit/useExtensionSignalValue.test.tsx > useExtensionSignalValue > re-renders when extension signal changes An update to EditorComponent inside a test was not wrapped in act(...). stderr | packages/lexical-react/src/__tests__/unit/LexicalExtensionComposer.test.tsx > LexicalExtensionComposer > $commitPendingUpdates flushes deferred callbacks even with no pending state updateEditorSync: an editor update (e.g. a command listener that mutates the editor) ran while a read-only context was on the stack. ... ``` ### After `npx vitest --project unit --project scripts-unit --no-watch --reporter=verbose run` produces zero stderr/stdout blocks: ``` Test Files 270 passed (270) Tests 5295 passed | 1 skipped (5296) ``` Co-Authored-By: Claude <[email protected]>
…s in the browser tests
## Description
`MdastEditorChrome.test.ts` clicked a footnote ref (or backlink) once and then
waited for the caret to arrive. The selection follow-up rides on the fragment
navigation's settle signal — `hashchange`, or a 100ms fallback for a
same-fragment click — and the navigation's focus fixup can land later still,
clobbering the one application. On the extended CI matrix (windows-2022,
firefox) that lost race timed the `vi.waitFor` out intermittently at
MdastEditorChrome.test.ts:328.
The obvious fix — defer the follow-up one task past the settle signal — is
wrong, and demonstrably so: with the deferral in place the read-only
navigation test fails *deterministically* on both chromium and firefox here. A
probe shows why: the deferred application lands (`inDef=true` immediately
after the update) and is then clobbered by fallout arriving later still
(`inDef=false` 300ms on, `activeElement` stuck on BODY, where an
`editable(false)` root cannot take focus back). Applying inside the dispatch is
what lets the application win the common case; deferring just changes who
loses. The extension is therefore untouched.
The tests instead retry the *interaction* rather than only the observation:
the click moves inside the `vi.waitFor`, so each poll clicks again. A repeat
click is a same-fragment navigation, which takes the timeout fallback and
re-applies the selection — the same recovery a person gets by clicking again.
All four click sites get the same shape (the ref click, both backlink clicks,
and the read-only ref click).
## Test plan
### Before
Intermittent on the extended matrix — Lexical Tests (Extended) /
browser-tests (windows-2022, firefox):
```
FAIL dev-examples/mdast-editor/src/__tests__/browser/MdastEditorChrome.test.ts
clicking a ref moves the caret into the definition body
❯ MdastEditorChrome.test.ts:328:27
❯ MdastEditorChrome.test.ts:316:13
```
Not reproducible here in 6 chromium and 6 firefox runs of the unmodified file
(linux; webkit cannot launch in this container, and the repo's own CI skips
webkit deps on linux).
### After
```
$ for i in 1..5; do VITEST_BROWSER=firefox npx vitest run --project browser dev-examples/mdast-editor/src/__tests__/browser/MdastEditorChrome.test.ts; done
Tests 19 passed (19) x5
$ for i in 1..3; do npx vitest run --project browser dev-examples/mdast-editor/src/__tests__/browser/MdastEditorChrome.test.ts; done
Tests 19 passed (19) x3
```
The whole browser project still passes:
```
$ npx vitest run --project browser
Test Files 18 passed (18)
Tests 131 passed | 1 skipped (132)
```
The windows-2022 leg of the matrix could not be exercised here; the retry
shape converges under any ordering of the navigation fallout, which is the
failure mode the CI job showed.
Co-Authored-By: Claude <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
marked this pull request as ready for review
August 25, 2026 18:20
etrepum
requested review from
acywatson,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 25, 2026 18:20
zurfyx
approved these changes
Aug 25, 2026
unix-max
pushed a commit
to unix-max/lexical
that referenced
this pull request
Aug 28, 2026
…#9098) Co-authored-by: Claude <[email protected]>
Merged
This branch was successfully deployed
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.
Description
pnpm run test-unitpasses, but the default reporter shows numerous stderr blocks of DEV-mode warnings that are all either missing test configuration or expected warnings from deliberately-exercised anti-patterns. This change makes the unit test run warning-free without changing any library behavior.Also adds a flakiness fix for a mdast-editor browser unit test in firefox.
Test plan
Test-only change, tests should still pass and exercise the same code paths without the noise from warning.