Skip to content

[tests] Chore: silence unnecessary stderr warnings in test-unit - #9098

Merged
etrepum merged 3 commits into
meta:mainfrom
etrepum:claude/test-unit-warnings-cleanup-qnwohq
Aug 25, 2026
Merged

etrepum merged 3 commits into
meta:mainfrom
etrepum:claude/test-unit-warnings-cleanup-qnwohq

Conversation

@etrepum

@etrepum etrepum commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Description

pnpm run test-unit passes, 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.

claude added 2 commits August 25, 2026 15:59
…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]>
@vercel

vercel Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview Aug 25, 2026 5:58pm
lexical-playground Ready Ready Preview Aug 25, 2026 5:58pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 25, 2026
@etrepum
etrepum added this pull request to the merge queue Aug 25, 2026
Merged via the queue into meta:main with commit 95a6624 Aug 25, 2026
48 checks passed
unix-max pushed a commit to unix-max/lexical that referenced this pull request Aug 28, 2026
@etrepum etrepum mentioned this pull request Aug 31, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — 1628d6a1 Deployed Aug 25, 2026 by vercel[bot]
Preview – lexical-playground — 1628d6a1 Deployed Aug 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants