Skip to content

[benchmarks] Chore: Migrate benchmarks to vitest 5 and add type checking in CI - #9235

Merged
etrepum merged 3 commits into
meta:mainfrom
etrepum:fix/vitest-5-benchmarks
Sep 25, 2026
Merged

etrepum merged 3 commits into
meta:mainfrom
etrepum:fix/vitest-5-benchmarks

Conversation

@etrepum

@etrepum etrepum commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Description

The vitest 5 upgrade broke the benchmarks, but we don't run or test their types in CI. Agents would notice this and complain, but nothing was in the critical path so it went unfixed. This adds the types to CI so future breakage will get caught during the upgrade rather than after.

Closes #9194

Test plan

tsc now runs over the benchmarks during ci-check

## Description

The Vitest upgrade removed the top-level bench export, leaving five benchmark
files untypeable and their runtime entry point unable to select a project.

Use the test-context bench fixture, explicit run/compare calls, and supported
benchmark lifecycle hooks. Preserve the paste benchmark's untimed per-iteration
reset and verification, and keep timing options on run(). Narrow the previous
sibling to ParagraphNode in the delete-range workload. Update the benchmark
script's project filter and the README examples for Vitest 5.

## Test plan

### Before

```text
$ node_modules/.bin/tsc --noEmit -p tsconfig.test.json
packages/lexical/src/__bench__/dom/editorCycle.bench.ts(10,9): error TS2724: '"vitest"' has no exported member named 'bench'. Did you mean 'Bench'?
packages/lexical/src/__bench__/dom/editorOperations.bench.ts(10,9): error TS2724: '"vitest"' has no exported member named 'bench'. Did you mean 'Bench'?
packages/lexical/src/__bench__/dom/editorOperations.bench.ts(136,15): error TS2740: Type 'LexicalNode' is missing the following properties from type 'ParagraphNode': extractWithChild, insertNewAfter, collapseAtStart, __first, and 57 more.
packages/lexical/src/__bench__/dom/editorOperations.bench.ts(221,16): error TS7006: Parameter 'task' implicitly has an 'any' type.
packages/lexical/src/__bench__/getWritable.bench.ts(9,9): error TS2724: '"vitest"' has no exported member named 'bench'. Did you mean 'Bench'?
packages/lexical/src/__bench__/nodeMap.bench.ts(9,9): error TS2724: '"vitest"' has no exported member named 'bench'. Did you mean 'Bench'?
packages/lexical/src/__bench__/serialization.bench.ts(10,9): error TS2724: '"vitest"' has no exported member named 'bench'. Did you mean 'Bench'?
```

### After

```text
$ node_modules/.bin/tsc --noEmit -p tsconfig.test.json
exit_code: 0 (no diagnostics)

$ npm run bench -- getWritable editorCycle editorOperations --reporter verbose
 Test Files  3 passed (3)
      Tests  32 passed (32)

$ node_modules/.bin/vitest bench --project 'bench*' --run nodeMap --testNamePattern '^size=100 :: clone$' --reporter verbose --pool=threads
 Test Files  1 passed (1)
      Tests  1 passed | 23 skipped (24)
```

ESLint, Prettier and git diff --check pass for the changed files.
The serialization benchmark's three cases also passed during a broader run;
the full node-map size/workload sweep was not completed.
## Description

CI only ran the root TypeScript config, which excludes benchmarks. Add
`tsc-test` for tsconfig.test.json and run it in `ci-check`, so the existing
integrity job catches benchmark API/type regressions. Document this coverage.

Also update the standalone production benchmark runner's Vitest shim for the
test-context bench API introduced by the preceding commit. Await asynchronous
case collection and map the new lifecycle hooks to the runner's setup and
verification callbacks.

## Test plan

### Before

```text
$ npm run tsc-test
npm error Missing script: "tsc-test"

$ LEXICAL_BENCH_FILTER='^$' LEXICAL_BENCH_SAMPLES=1 node scripts/bench-get-writable.mjs HEAD
ERROR: No matching export in "benchmark:vitest" for import "test"
```

### After

```text
$ npm run tsc-test
> @lexical/[email protected] tsc-test
> tsc -p ./tsconfig.test.json
exit_code: 0 (no diagnostics)

$ npm run tsc-test -- --listFilesOnly
# Verified compiler output includes all five benchmark files.

$ node_modules/.bin/tsc -p tsconfig.scripts.json
exit_code: 0 (no diagnostics)

$ LEXICAL_BENCH_SAMPLES=1 node scripts/bench-get-writable.mjs HEAD^
exit_code: 0
# Validated JSON output:
Production runner: all 12 workloads completed and verified for HEAD^ and WORKTREE.
```

Prettier, ESLint, and git diff --check pass for the changed files.
@vercel

vercel Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
lexical Ready Ready Preview Sep 25, 2026 3:42pm UTC
lexical-playground Ready Ready Preview Sep 25, 2026 3:42pm UTC

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 Sep 25, 2026
@etrepum
etrepum added this pull request to the merge queue Sep 25, 2026
Merged via the queue into meta:main with commit 6ddbcd2 Sep 25, 2026
46 checks passed
@etrepum etrepum mentioned this pull request Sep 28, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — ced46ada Deployed Sep 25, 2026 by vercel[bot]
Preview – lexical-playground — ced46ada Deployed Sep 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants