Skill: testing
Push the suite toward three layers only:
Hard constraints:
bun run test is the default iterative workflow.pnpm test:all is the full end-of-task and CI run. Do not use it as the default inner-loop command.lcov. Trust file order more than package totals.>= 6>= 5/react is not permanently excluded. Exclude it only when the current pass explicitly says so.tooling/config/global.d.ts. Do not import describe, it, expect, mock, spyOn, or other globals from bun:test.*.spec.ts[x] for the fast lane and *.slow.ts[x] for the slow lane.type-tests/, not mixed into runtime specs.devDependencies just to support cross-package or app-shaped test setups. If a test needs other package kits, app aliases, or multi-package wiring, move it to apps/www/src/__tests__/package-integration.bun run test:profile. bun run test:slowest is the hard gate. If a fast-suite spec crosses the thresholds in tooling/config/test-suites.mjs, rename it to *.slow.ts[x].60ms/test or 120ms/file is already a move candidate, especially for React-heavy specs.pnpm test:slowest -- --top 25 --rerun-each 3 and move repeat offenders before they drift over the CI line.tooling/config/bunTestSetup.ts, not by changing runtime code or sprinkling per-spec console mocks.createEditor from @platejs/slate for pure Slate query, transform, interface, and history contracts.createSlateEditor for non-React plugin or editor wiring:
insertDatacreatePlateEditor only when the contract is genuinely Plate-specific.createPlateEditor usage is a reviewed allowlist, not a future cleanup queue.__tests__/ only for:
__tests__/.it() body.getSortedKeys(...) and createStoreEditor(...) beat repeated editor construction sludge.NodeApi and ElementApi do not treat plain { children: [...] } objects the same way as real editors.it.each for small behavior matrices.screen.toBe(...) string assertions.toHaveStyle here. Use direct style-property assertions instead.bun test -u updates and adds keys, but does not reliably prune dead ones.lcov after each pass. Do not keep working from a stale hotspot map.it.each(...) format stringsString.raw titlesit, test, and describe blocks during dead-spec cleanup waves.createPlateEditor seamsbun run test:profile for the fast suite when deciding whether a spec belongs in the slow lane. pnpm test:slowest and pnpm check enforce those thresholds.autoformatKEYS or base plugins, not React plugin .key.AutoformatKit or app registries in package tests.autoformat case needs cross-package behavior like code-block wiring or app-owned integration setup, move it to apps/www/src/__tests__/package-integration instead of expanding packages/autoformat/package.json.markdownMarkdownPlugin locally in the package helper.MarkdownKit or any app registry from apps/www.ai / streaming markdowncorecreateSlateEditor for:
insertDataPlate while the same run also loads public-package React entrypoints, treat duplicate-instance warnings as test noise. Suppress them in the test wrapper with suppressInstanceWarning instead of changing runtime warning logic.packages/core/src/react/__tests__/TestPlate.tsx helper instead of re-declaring local const Plate = ... wrappers.selectionmoveSelection and shiftSelection stay on Plate. They are genuinely Plate-bound exceptions, not cleanup debt.docx, docx-io, and app integrationapps/www/src/__tests__/package-integration.src/lib.docx and docx-io suites are valid reasons to keep __tests__/.slatecreateEditor legacy sync.@platejs/slate contracts.lcov as package truth. Bun’s text coverage summary is noisy for targeted package runs.slate-react invariants:
use-slate-selector: selector equality and stale-rerender preventionuse-slate: editor version and subscription behavioruse-selected: selection rerender and path stabilityeditable: value-change vs selection-change partitioningdecorations: decoration propagation and redecorate behaviorchunking: chunk or index invalidation only if remaining core gaps justify itreact-editor DOM focus coverage unless a real Plate bug forces it.createPlateEditor allowlistKeep createPlateEditor when the contract is actually about:
moveSelection and shiftSelectionDo not treat these files as backlog just because they still use Plate.
__tests__/ allowlistKeep __tests__/ when it holds:
withAutoformatdocx and docx-ioapps/www/src/__tests__/package-integrationcreateEditor -> createSlateEditor -> createPlateEditor.>= 6 first, rerun coverage, then worthwhile >= 5, then switch to architecture-safety targets.bun run test for the fast default loop. Use pnpm test:all for the full suite.bun run test:profile to inspect the fast loop and bun run test:slowest to enforce it.pnpm test:slowest has two bands: warning zone for local drift and hard CI failure thresholds. Fix the warning zone before it becomes a PR failure.bun:test.__tests__/ only for helpers, fixtures, or intentional split or integration suites.screen, and use direct style-property assertions over toHaveStyle.lcov, not Bun’s broad text summary.*.spec.ts[x], run by pnpm test*.slow.ts[x], run by pnpm test:slowpnpm test:all for the full repo test run instead of relying on bare bun test.