test: useLiveQuery conformance suite across all five framework adapters (RFC #1623) #1636
main fromrefs/pull/1636/head·merged by kevin-dp(GitHub profile, opens in a new tab) Draft — first slice of RFC #1623 (framework-binding platform). Discussion: https://github.com/TanStack/db/issues/1623
Scope — this is test infrastructure only#
This PR is entirely test-only — no src/ changes, no shared production code. It does not extract the duplicated adapter logic into a shared observer/module; that's the next milestone (RFC step 2+). This PR builds the safety net that must exist before that extraction, so we can rip shared logic out of five adapters and prove behavior is unchanged.
The per-framework files here (packages/*/tests/conformance.test.*) are small test harnesses, not new production abstractions. Each just wraps its framework's existing useLiveQuery (mount → read → flush → unmount) so one shared spec can run against all five. (In the code the harness interface is named LiveQueryDriver — "driver" in the JUnit/conformance-testing sense of "the thing that drives the tests," not a runtime adapter.)
What this is#
A shared, framework-agnostic conformance suite for the useLiveQuery adapters. One behavioral spec (packages/db/tests/conformance/suite.ts, 24 scenarios) runs against all five adapters through a thin per-framework test harness implementing a common contract (packages/db/tests/conformance/contract.ts).
This is deliberately the lowest-risk, highest-consensus piece of #1623: it documents current behavior, commits to no architecture, and becomes the safety net for the later observer/adapter refactor.
How it's sourced#
Bottom-up from the union of the existing adapter test suites — every fixed bug already left a regression test behind, so those tests are the real contract. The diff between adapters' suites is the drift #1623 is about, so folding them into one spec surfaces it. The RFC's aspirational list contributes only the small additive tail (the #1601 order-only-move case, a universal expected-fail).
Design notes#
- Realm-safe injection. The per-framework harness — not the scenarios — creates collections and supplies query operators, both from the adapter's
@tanstack/db. Scenarios never import@tanstack/db, avoiding the dual-packageinstanceof CollectionImplmismatch. - Per-adapter
knownGaps, populated empirically. Each scenario runs asitorit.failsper adapter based onknownGaps. A key is added only when it actually fails on a run — the matrix says where to look, the run says what's broken. When a gap closes,it.failserrors ("expected to fail but passed") prompting removal. So drift and bugs are documented without the suite going red, and theknownGapslists double as the follow-up to-do list. apply(fn)handle primitive. A cross-framework "run a mutation inside the framework's update scope, then settle" (Reactact/ VuenextTick/ SvelteflushSync/ Solidbatch) — needed for the optimistic-mutation scenario.
Coverage (24 scenarios)#
Query/where/select, live insert/update/delete, orderBy, join, groupBy/aggregate, nested aggregates, .includes subqueries, findOne cardinality (+ reactive update/delete), disabled + enable/disable transitions, deferred readiness / eager-visible-while-loading / ready-with-no-data, param recompilation, optimistic mutation, pre-created & config-object inputs, error status, and the #1601 order-only-move tail.
Results — all five adapters covered#
Each passes 24/24 (documented knownGaps run as expected-fail). The suite surfaced three real cross-adapter divergences/bugs:
| Adapter | knownGaps | Finding | Fix |
|---|---|---|---|
| React | — | reference harness, clean | — |
| Vue | — | clean — and closes Vue's findOne coverage gap (vue-db had zero findOne tests; it works, was just untested) | — |
| Svelte | disabled-explicit, disabled-transition | Bug: toValue() (added for the reactive () => collection form) calls a () => null disabled query as a getter, unwraps it to null, and passes {...null} into createLiveQueryCollection → crash in getQueryIR. The disabled short-circuit is unreachable; svelte-db has no disabled tests. | #1637 |
| Solid | error-status | Divergence: errors are surfaced by throwing (CollectionStateError) through the createResource/Suspense path for an <ErrorBoundary>, not via a readable isError flag like the others. | #1639 |
| Angular | config-object-input | Divergence: the plain { query } config path calls createLiveQueryCollection(opts) without injecting startSync: true (its query-fn path does), so a bare config never syncs. The others auto-start; Angular requires explicit startSync: true. | #1638 |
Also confirmed not drift: every adapter eagerly starts a pre-created collection on mount (an earlier scenario wrongly tested this as React-specific; corrected to build over a not-ready source so it measures the actual contract — isReady stays false only when the source never readies).
Out of scope for this suite (by design)#
Framework-specific tests (Solid proxy identity, Svelte runes, React overloads, Angular DI lifecycle) stay per-adapter. Separate hook families (useLiveInfiniteQuery, useLiveSuspenseQuery, useLiveQueryEffect) get their own suites later.
Follow-up PRs (stacked on this branch)#
Each clears one knownGap and is stacked on this branch (re-target to main once this lands):
- #1637 —
fix(svelte-db): the disabled-query crash (the only outright bug). Clearsdisabled-explicit+disabled-transition. - #1638 —
fix(angular-db): config-object input now syncs (defaultsstartSync: true). Clearsconfig-object-input. - #1639 —
test(conformance): parametrizes error surfacing (errorSurface: 'flag' | 'throw') rather than "fixing" Solid's idiomatic ErrorBoundary model. Clearserror-status.
Each removes its knownGap entry, so the previously-it.fails scenario runs as a normal passing test — the suite itself proves the fix.
Next milestone (NOT this PR)#
The actual duplication cleanup — extracting the ~7 items each adapter copies (input normalization, disabled handling, cardinality, status derivation, ready-race, etc.) into a shared observer/module in @tanstack/db, then slimming each adapter's src/useLiveQuery down to it — is a separate follow-up. That's the PR that will show src/ changes and shrink duplication. This suite exists to keep it honest: it must stay green through that refactor.
🤖 Generated with Claude Code
Summary by CodeRabbit#
- New Features
- Added a shared live-query conformance test suite.
- Added adapter drivers for Angular, React, Solid, Svelte, and Vue so the same query scenarios run consistently across frameworks.
- Expanded coverage for filtering, inserts/updates/deletes, ordering, joins, grouping, deferred loading, disabled queries, errors, and optimistic updates.
- Bug Fixes
- Added expected-fail tracking to keep known framework differences from breaking the suite.
- Improved cleanup so mounted queries are torn down after each scenario.
- 1
More templates
@tanstack/angular-db
npm i https://pkg.pr.new/@tanstack/angular-db@1636@tanstack/browser-db-sqlite-persistence
npm i https://pkg.pr.new/@tanstack/browser-db-sqlite-persistence@1636@tanstack/capacitor-db-sqlite-persistence
npm i https://pkg.pr.new/@tanstack/capacitor-db-sqlite-persistence@1636@tanstack/cloudflare-durable-objects-db-sqlite-persistence
npm i https://pkg.pr.new/@tanstack/cloudflare-durable-objects-db-sqlite-persistence@1636@tanstack/db
npm i https://pkg.pr.new/@tanstack/db@1636@tanstack/db-ivm
npm i https://pkg.pr.new/@tanstack/db-ivm@1636@tanstack/db-sqlite-persistence-core
npm i https://pkg.pr.new/@tanstack/db-sqlite-persistence-core@1636@tanstack/electric-db-collection
npm i https://pkg.pr.new/@tanstack/electric-db-collection@1636@tanstack/electron-db-sqlite-persistence
npm i https://pkg.pr.new/@tanstack/electron-db-sqlite-persistence@1636@tanstack/expo-db-sqlite-persistence
npm i https://pkg.pr.new/@tanstack/expo-db-sqlite-persistence@1636@tanstack/node-db-sqlite-persistence
npm i https://pkg.pr.new/@tanstack/node-db-sqlite-persistence@1636@tanstack/offline-transactions
npm i https://pkg.pr.new/@tanstack/offline-transactions@1636@tanstack/powersync-db-collection
npm i https://pkg.pr.new/@tanstack/powersync-db-collection@1636@tanstack/query-db-collection
npm i https://pkg.pr.new/@tanstack/query-db-collection@1636@tanstack/react-db
npm i https://pkg.pr.new/@tanstack/react-db@1636@tanstack/react-native-db-sqlite-persistence
npm i https://pkg.pr.new/@tanstack/react-native-db-sqlite-persistence@1636@tanstack/rxdb-db-collection
npm i https://pkg.pr.new/@tanstack/rxdb-db-collection@1636@tanstack/solid-db
npm i https://pkg.pr.new/@tanstack/solid-db@1636@tanstack/svelte-db
npm i https://pkg.pr.new/@tanstack/svelte-db@1636@tanstack/tauri-db-sqlite-persistence
npm i https://pkg.pr.new/@tanstack/tauri-db-sqlite-persistence@1636@tanstack/trailbase-db-collection
npm i https://pkg.pr.new/@tanstack/trailbase-db-collection@1636@tanstack/vue-db
npm i https://pkg.pr.new/@tanstack/vue-db@1636commit:
3f6a9e5Size Change: 0 B
Total Size: 125 kB
compressed-size-action::db-package-sizeℹ️ View Unchanged
Filename Size packages/db/dist/esm/collection/change-events.js1.43 kB packages/db/dist/esm/collection/changes.js1.38 kB packages/db/dist/esm/collection/cleanup-queue.js810 B packages/db/dist/esm/collection/events.js434 B packages/db/dist/esm/collection/index.js3.62 kB packages/db/dist/esm/collection/indexes.js1.99 kB packages/db/dist/esm/collection/lifecycle.js1.69 kB packages/db/dist/esm/collection/mutations.js2.47 kB packages/db/dist/esm/collection/state.js5.4 kB packages/db/dist/esm/collection/subscription.js3.74 kB packages/db/dist/esm/collection/sync.js2.88 kB packages/db/dist/esm/collection/transaction-metadata.js144 B packages/db/dist/esm/deferred.js207 B packages/db/dist/esm/errors.js5.1 kB packages/db/dist/esm/event-emitter.js748 B packages/db/dist/esm/index.js3.1 kB packages/db/dist/esm/indexes/auto-index.js829 B packages/db/dist/esm/indexes/base-index.js767 B packages/db/dist/esm/indexes/basic-index.js2.06 kB packages/db/dist/esm/indexes/btree-index.js2.19 kB packages/db/dist/esm/indexes/index-registry.js820 B packages/db/dist/esm/indexes/reverse-index.js557 B packages/db/dist/esm/local-only.js916 B packages/db/dist/esm/local-storage.js2.12 kB packages/db/dist/esm/optimistic-action.js359 B packages/db/dist/esm/paced-mutations.js496 B packages/db/dist/esm/proxy.js3.75 kB packages/db/dist/esm/query/builder/functions.js1.47 kB packages/db/dist/esm/query/builder/index.js5.84 kB packages/db/dist/esm/query/builder/ref-proxy.js1.24 kB packages/db/dist/esm/query/compiler/evaluators.js1.89 kB packages/db/dist/esm/query/compiler/expressions.js430 B packages/db/dist/esm/query/compiler/group-by.js3.56 kB packages/db/dist/esm/query/compiler/index.js6.67 kB packages/db/dist/esm/query/compiler/joins.js2.5 kB packages/db/dist/esm/query/compiler/lazy-targets.js923 B packages/db/dist/esm/query/compiler/order-by.js1.74 kB packages/db/dist/esm/query/compiler/select.js1.53 kB packages/db/dist/esm/query/effect.js4.77 kB packages/db/dist/esm/query/expression-helpers.js1.43 kB packages/db/dist/esm/query/ir.js1.25 kB packages/db/dist/esm/query/live-query-collection.js360 B packages/db/dist/esm/query/live/collection-config-builder.js9.1 kB packages/db/dist/esm/query/live/collection-registry.js264 B packages/db/dist/esm/query/live/collection-subscriber.js1.93 kB packages/db/dist/esm/query/live/internal.js145 B packages/db/dist/esm/query/live/utils.js1.81 kB packages/db/dist/esm/query/optimizer.js2.92 kB packages/db/dist/esm/query/predicate-utils.js2.97 kB packages/db/dist/esm/query/query-once.js359 B packages/db/dist/esm/query/subset-dedupe.js960 B packages/db/dist/esm/scheduler.js1.3 kB packages/db/dist/esm/SortedMap.js1.3 kB packages/db/dist/esm/strategies/debounceStrategy.js247 B packages/db/dist/esm/strategies/queueStrategy.js428 B packages/db/dist/esm/strategies/throttleStrategy.js246 B packages/db/dist/esm/transactions.js3.04 kB packages/db/dist/esm/utils.js927 B packages/db/dist/esm/utils/array-utils.js273 B packages/db/dist/esm/utils/browser-polyfills.js304 B packages/db/dist/esm/utils/btree.js5.61 kB packages/db/dist/esm/utils/comparison.js1.11 kB packages/db/dist/esm/utils/cursor.js457 B packages/db/dist/esm/utils/index-optimization.js2.39 kB packages/db/dist/esm/utils/type-guards.js157 B packages/db/dist/esm/utils/uuid.js449 B packages/db/dist/esm/virtual-props.js360 B Size Change: 0 B
Total Size: 4.26 kB
compressed-size-action::react-db-package-sizeℹ️ View Unchanged
Filename Size packages/react-db/dist/esm/index.js249 B packages/react-db/dist/esm/useLiveInfiniteQuery.js1.32 kB packages/react-db/dist/esm/useLiveQuery.js1.37 kB packages/react-db/dist/esm/useLiveQueryEffect.js355 B packages/react-db/dist/esm/useLiveSuspenseQuery.js567 B packages/react-db/dist/esm/usePacedMutations.js401 B kevin-dp(GitHub profile, opens in a new tab) changed the title
kevin-dp(GitHub profile, opens in a new tab) changed the title
KyleAMathews(GitHub profile, opens in a new tab) approved these changes
I think the conformance-suite shape is good, and I’m approving this direction. I did a pass over an external review and validated a few test-infrastructure issues that seem worth addressing, either in this PR or a quick follow-up:
The React conformance driver currently derives normalized
isEnabledfromstatus !== 'disabled', so the suite doesn’t actually catch a broken ReactisEnabledvalue. I verified by intentionally returningisEnabled: truefor disabled React queries: the conformance test still passed. Mapping React’s normalized field fromr.isEnabledmakes the disabled conformance scenarios catch it. For adapters that don’t expose a realisEnabledfield/signal, deriving from status is fine, but the normalized field should probably be named/treated honestly as status-derived.Expected-fail scenarios can leak mounted framework roots because
h.unmount()is after assertions. I instrumented Solid roots and saw leaks from the expected-failerror-statusand universalorder-only-movescenarios. Wrapping mounted handles intry/finally { h.unmount() }fixes it.knownGapsshould be validated against registered scenario keys. I added a bogus React gap and the suite still passed. A smallscenarioKeysset plus validation test catches stale/misspelled gaps.includes-subqueryis under-asserted. The suggested stronger assertion is directionally right, thoughjohnSmith.issuesis a child collection rather than[], so the strengthened assertion should read child collection contents through the collection API.The
suite.tsheader is stale: it says engine-heavy scenarios are “ported next,” but this PR already includes them.
I also checked for bidi/Trojan Source controls in the added conformance files and didn’t find any, so I wouldn’t block on that.
Thanks for the careful pass, Kyle — all five were legit. Addressed each as its own commit on this branch:
React
isEnabledwas status-derived, masking a broken value (e5c131fb) — the React driver now maps the normalized field fromr.isEnabled, so the disabled scenarios actually catch it. The other four adapters don't expose anisEnabled, so they keep the status-derived value with an explicit comment noting that.Expected-fail scenarios leaked mounted roots (
457d1099) — themount*methods are now wrapped to track every handle, and each scenario tears them all down in afinally, so teardown runs even when a scenario throws before its ownh.unmount(). This covers both the universalorder-only-moveand any per-adapterknownGap(e.g. Soliderror-status).knownGapsweren't validated (596bba2c) — every scenario key is now registered, and a test asserts each driver'sknownGaps(andUNIVERSAL_EXPECTED_FAIL) reference a real key. I confirmed it catches a bogus/misspelled gap. Handy since gaps are churning across the follow-up fix PRs.includes-subquerywas under-asserted (4c117967) — you're right thatjohn.issuesis a child collection, so it now reads the contents through the collection API and asserts John (id 1) has exactlyi1andi3.Stale header (
bed14e62) — replaced the "ported next" STATUS note with the actual coverage list.
All five suites stay green at 25/25 (the +1 is the new
knownGapsvalidation). No changes needed for the bidi/Trojan-source note. The rest of the stack (#1641/#1642 and the three fix PRs) has been rebased onto this and re-verified.kevin-dp(GitHub profile, opens in a new tab) closed this
🧹 Nitpick comments (4)
packages/db/tests/conformance/suite.ts (3)
88-94: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winSilent teardown catch-all may mask real driver bugs.
Every
handle.unmount()failure is swallowed unconditionally. Since the whole point of this suite is to surface adapter-specific defects, an unmount that throws for a genuine bug (not just idempotent double-unmount) will be silently hidden rather than surfaced as a signal for someone to investigate.♻️ Suggested tweak: log instead of fully silencing
for (const handle of handles) { try { handle.unmount() - } catch { - // teardown is best-effort / idempotent + } catch (err) { + // teardown is best-effort / idempotent, but still surface unexpected + // failures for diagnosis instead of hiding them entirely. + console.warn(`[conformance] handle.unmount() failed during teardown:`, err) } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/db/tests/conformance/suite.ts` around lines 88 - 94, The teardown loop in the conformance suite is swallowing every `handle.unmount()` error, which can hide real adapter bugs. Update the `handles` cleanup block in `suite.ts` so `handle.unmount()` failures are not silently ignored; instead, log the caught error with enough context to identify which handle failed, while still keeping teardown best-effort and idempotent.
104-176: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRepeated
makeSource + mount(select id) + flushboilerplate across scenarios.Several scenarios (
basic-select,live-insert,live-delete,orderby,live-update, etc.) repeat the samedriver.makeSource(SEED)→driver.mount(...select id...)→await h.flush()setup. Extracting a small helper (e.g.mountIdSelect(source)) would reduce duplication and keep each scenario body focused on its assertion.As per coding guidelines, "Extract common logic into utility functions when identical or near-identical code blocks appear in multiple places."
Also applies to: 358-400
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/db/tests/conformance/suite.ts` around lines 104 - 176, The test scenarios repeat the same driver.makeSource(SEED) and driver.mount(...) setup with an id-only select, so extract that shared initialization into a small helper and reuse it across the conformance scenarios. Add a utility such as a mount helper near the suite-level test setup, then update the affected scenarios like basic-select, live-insert, live-delete, and orderby to call it and keep only the scenario-specific assertions and mutations.Source: Coding guidelines
104-676: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftPervasive
anytyping in scenario callbacks.Nearly every query-builder callback throughout the file is typed as
(q: any)/({ items }: any)/({ items, persons }: any), etc. (e.g. Lines 112-113, 130-131, 244-251, 296-313, 332-339). This runs counter to the guideline requiringunknown+ type guards overany. Given each adapter passes its own framework-specific generic query builder, fully eliminatinganymay require nontrivial generic plumbing throughcontract.ts'sQueryBuildtype — worth considering for a follow-up rather than blocking this draft suite.As per coding guidelines, "Avoid using
anytypes; useunknowninstead when the type is truly unknown, and provide proper type annotations for return values."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/db/tests/conformance/suite.ts` around lines 104 - 676, The scenario callbacks in this conformance suite rely on pervasive any annotations in query-builder lambdas, which conflicts with the typing guideline. Replace these callback parameters in the suite’s scenario definitions and query expressions (such as the mounts using q, items, persons, issues, ic) with properly typed generics or unknown plus narrowing, using the relevant driver/query-builder types instead of any. If full typing is not practical here, wire the generic query-builder type through the shared QueryBuild/contract layer so the callbacks can infer concrete shapes without any.Source: Coding guidelines
packages/react-db/tests/conformance.test.tsx (1)
41-121: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winIdentical boilerplate duplicated across all 5 driver files.
writer,makeSource,makeDeferredSource,makePrecreated, andmakeErrorSourceare byte-for-byte identical (modulo the id prefix string) in the Angular, Vue, Svelte, and Solid driver files. Since each only needscreateCollection,createLiveQueryCollection,mockSyncCollectionOptions, andmockSyncCollectionOptionsNoInitialState(all realm-specific), this can be extracted into a shared parameterized factory inpackages/db/tests/conformance/that each driver calls with its own realm imports and prefix.The PR notes state shared-logic extraction is deferred to a later stacked refactor, so this is a good-to-have rather than a blocker for this draft.
♻️ Illustrative extraction (outside current file's line range)
// packages/db/tests/conformance/sourceFactories.ts export function createSourceFactories<Realm extends { createCollection: typeof import('`@tanstack/db`').createCollection createLiveQueryCollection: typeof import('`@tanstack/db`').createLiveQueryCollection }>(realm: Realm, mocks: { mockSyncCollectionOptions: typeof mockSyncCollectionOptions mockSyncCollectionOptionsNoInitialState: typeof mockSyncCollectionOptionsNoInitialState }, prefix: string) { let sourceSeq = 0 function writer<T extends { id: string }>(collection: any) { /* shared body */ } function makeSource<T extends { id: string }>(initialData: ReadonlyArray<T>) { /* shared body */ } function makeDeferredSource<T extends { id: string }>() { /* shared body */ } function makePrecreated(build: QueryBuild, opts?: { startSync?: boolean }) { /* shared body */ } function makeErrorSource() { /* shared body */ } return { makeSource, makeDeferredSource, makePrecreated, makeErrorSource } }Then this file's lines 41-121 collapse to a single call:
-let sourceSeq = 0 - -function writer<T extends { id: string }>(collection: any) { ... } -function makeSource<T extends { id: string }>(...) { ... } -function makeDeferredSource<T extends { id: string }>() { ... } -function makePrecreated(build: QueryBuild, opts?: { startSync?: boolean }) { ... } -function makeErrorSource() { ... } +const { makeSource, makeDeferredSource, makePrecreated, makeErrorSource } = + createSourceFactories( + { createCollection, createLiveQueryCollection }, + { mockSyncCollectionOptions, mockSyncCollectionOptionsNoInitialState }, + `conformance-react`, + )As per coding guidelines, "Extract common logic into utility functions when identical or near-identical code blocks appear in multiple places."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/react-db/tests/conformance.test.tsx` around lines 41 - 121, The conformance test helpers here are duplicated across the driver files, so extract the shared boilerplate into a parameterized factory under packages/db/tests/conformance and have this file consume it instead of defining writer, makeSource, makeDeferredSource, makePrecreated, and makeErrorSource locally. Keep the realm-specific pieces (createCollection, createLiveQueryCollection, mockSyncCollectionOptions, mockSyncCollectionOptionsNoInitialState, and the id prefix/sourceSeq handling) as injected dependencies so each driver can reuse the same implementation.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Nitpick comments: In `@packages/db/tests/conformance/suite.ts`: - Around line 88-94: The teardown loop in the conformance suite is swallowing every `handle.unmount()` error, which can hide real adapter bugs. Update the `handles` cleanup block in `suite.ts` so `handle.unmount()` failures are not silently ignored; instead, log the caught error with enough context to identify which handle failed, while still keeping teardown best-effort and idempotent. - Around line 104-176: The test scenarios repeat the same driver.makeSource(SEED) and driver.mount(...) setup with an id-only select, so extract that shared initialization into a small helper and reuse it across the conformance scenarios. Add a utility such as a mount helper near the suite-level test setup, then update the affected scenarios like basic-select, live-insert, live-delete, and orderby to call it and keep only the scenario-specific assertions and mutations. - Around line 104-676: The scenario callbacks in this conformance suite rely on pervasive any annotations in query-builder lambdas, which conflicts with the typing guideline. Replace these callback parameters in the suite’s scenario definitions and query expressions (such as the mounts using q, items, persons, issues, ic) with properly typed generics or unknown plus narrowing, using the relevant driver/query-builder types instead of any. If full typing is not practical here, wire the generic query-builder type through the shared QueryBuild/contract layer so the callbacks can infer concrete shapes without any. In `@packages/react-db/tests/conformance.test.tsx`: - Around line 41-121: The conformance test helpers here are duplicated across the driver files, so extract the shared boilerplate into a parameterized factory under packages/db/tests/conformance and have this file consume it instead of defining writer, makeSource, makeDeferredSource, makePrecreated, and makeErrorSource locally. Keep the realm-specific pieces (createCollection, createLiveQueryCollection, mockSyncCollectionOptions, mockSyncCollectionOptionsNoInitialState, and the id prefix/sourceSeq handling) as injected dependencies so each driver can reuse the same implementation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID:
6fd94bb8-a36a-4a1d-b201-622045a3d01b📥 Commits
Reviewing files that changed from the base of the PR and between f7da77660b16cbfe30817fb5c938267d696c8d1c and 3f6a9e52393a98b17098b40bae7191cd0c4a5d1d.
📒 Files selected for processing (7)
packages/angular-db/tests/conformance.test.tspackages/db/tests/conformance/contract.tspackages/db/tests/conformance/suite.tspackages/react-db/tests/conformance.test.tsxpackages/solid-db/tests/conformance.test.tsxpackages/svelte-db/tests/conformance.svelte.test.tspackages/vue-db/tests/conformance.test.ts
Sign in to join this conversation.
📝 Walkthrough
Walkthrough#
Introduces a shared cross-framework live-query conformance test contract and suite (
packages/db/tests/conformance/contract.ts,suite.ts) defining common types and scenarios, along with six per-framework driver test files (Angular, React, Solid, Svelte, Vue) that implement the driver interface and register withrunSuiteto validate live-query behavior consistently across adapters.Changes#
Shared Conformance Contract and Suite
packages/db/tests/conformance/contract.tsRow,SourceHandle,DeferredSourceHandle,DbOps,ConformanceResult,QueryBuild,LiveQueryHandle,ControllableHandle, andLiveQueryDriverinterfaces shared by all adapters.packages/db/tests/conformance/suite.tsrunSuitetracks mounted handles, derives expected-fail keys fromknownGaps/UNIVERSAL_EXPECTED_FAIL, and defines seed fixtures.packages/db/tests/conformance/suite.tsFramework Driver Implementations
packages/react-db/tests/conformance.test.tsxuseLiveQuerymount helpers, a handle adapter, andreactDriverregistration.packages/angular-db/tests/conformance.test.tsinjectLiveQuerymounting viaEnvironmentInjector, a handle adapter, andangularDriverregistration.packages/vue-db/tests/conformance.test.tseffectScope-based mounting, a handle adapter, andvueDriverregistration.packages/svelte-db/tests/conformance.svelte.test.ts$effect.root-based mounting, a handle adapter withflushSyncsettling, andsvelteDriverregistration.packages/solid-db/tests/conformance.test.tsxsolidDriverregistration.Estimated code review effort: 3 (Moderate) | ~30 minutes
Sequence Diagram(s)#
Suggested reviewers:
samwillis🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
✨ Finishing Touches
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share