Repository navigation
Hold already-loaded lazy modules per test - #7746
Merged
Merged
Conversation
The app's lazy-import hold only held the import() call. A split or React.lazy component loaded by an earlier test rendered synchronously in later tests, so a test that asserted lazy content without waiting passed or failed with test order (ProjectPathDialog's single-machine test failed under shuffled seeds). The app test setup now gates defineSplit's loaded view and React.lazy so a module loaded before the current test renders its loading state on its first render until the test settles. A module loaded in the same test, or preloaded by the file during collection, renders at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ymichael
force-pushed
the
bb/lazy-module-hold-loaded-and-plugins
branch
from
November 18, 2026 04:23
e79922d to
ce86bb3
Compare
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.
Human comments
What was wrong
#7736 holds each dynamic
import()in@bb/apptests until the test settles it, but only the call itself. Once adefineSplitsplit or aReact.lazycomponent has loaded in a worker, later tests render it synchronously, so the hold never applies to them. A test that asserts lazy content without waiting therefore passes only when an earlier test or file loaded the module first.ProjectPathDialog.test.tsxon main shows this. In default order it passes: test 1 awaitsfindByRole, which loadsRemotePathBrowser, and test 2 then reads it synchronously. Run alone (-t "preserves the direct single-machine folder flow") it fails, and with--sequence.shuffleseeds 1, 3 and 8 fail (seed 1 is the nightly app-3 failure).What changed
Per-test gate for already-loaded modules (
apps/app/src/test/lazy-modules.ts,setup.ts). The app test setup now mocks two lazy helpers:defineSplit's loaded view withgateLoadedComponent.lazywithgateReactLazy.No production code changes. In each test, a split or lazy component that loaded before that test renders its real loading state on its first render, until the test settles (
settleLazyModules(),findByorwaitFor). A failing test names it, for examplesplit:remote-path-browser (held).Two cases render at once:
await Split.preload()exempts that split for the file's tests. That is explicit, order-independent fixture preparation.settleLazyModules()also loops until no new import starts during a pass. This covers an import started in a microtask after render, which could outlastfindBy's deadline.Tests moved onto the signal.
.htmcase settles before reading the source view.findBytimeouts and itsbeforeAllpreload.define-split.test.tsx: testsdefineSplit's own Suspense and preload mechanics, so it unmocksreactand./define-split.Docs:
docs/ui-code-splitting.md("Test lazy boundaries") describes the gate, the collection-time preload exemption and the unmock for mechanism tests.Scope. An earlier revision moved the hold into
@get-bb/plugin-sdkas sixexperimental_exports for plugins and@bb/shared-ui. That move is dropped, so this PR has no SDK, plugin, shared-ui or version changes. In-repo plugins have no lazy UI that their tests exercise:import(), already covered byvi.dynamicImportSettled().The hold can move into the SDK when a plugin needs it.
How you verified
ProjectPathDialog.test.tsxfails under this branch's gate in default order, withLazy imports had not settled when this test failed: split:remote-path-browser (held).apps/app/src/test/lazy-modules.test.tsx) cover:React.lazyheld until the test settles;pnpm exec turbo run typecheck lint lint:type-aware test --filter=@bb/apppasses (689 test files).🤖 Generated with Claude Code