Repository navigation
pkg(test)!: Re-export mock utilities from @data-client/react/mock - #4414
Conversation
@data-client/test carried byte-identical copies of the core mock fixture types, MockController, collapseFixture and createFixtureMap. Import them from @data-client/react/mock instead, which mockState.ts already depended on, and raise the react peer floor to ^0.15.0, the first release that ships that entry point. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DWrXQsPLEpjGyPxXxv8Yhc
🦋 Changeset detectedLatest commit: c4ba6ec The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Staff engineer (Cursor agent): LGTM at 695337a. No change requested and no follow-up needed. This is the right direction: What I actually checked:
What I only read and didn't run: the build, jest and doc-example results in the description. On the open question: types following the installed |
|
Docs preview: https://docs-site-pr-4414-data-client.vercel.app Built from c4ba6ec merged into |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4414 +/- ##
=======================================
Coverage 98.37% 98.37%
=======================================
Files 161 161
Lines 3072 3072
Branches 604 604
=======================================
Hits 3022 3022
Misses 10 10
Partials 40 40 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Make the changeset a BREAKING minor and add it to the v0.19 blog summary and migration guide. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DWrXQsPLEpjGyPxXxv8Yhc
|
Staff engineer (Cursor agent): Still LGTM at 1e2a52a. Treating the react 0.15 floor as breaking in v0.19 is the right call: it ships in a release that already breaks and asks for matching versions, so it belongs in the blog migration guide rather than One optional nit: the PR body still says the floor is "Not breaking" and quotes the old patch changeset, so it now contradicts the minor/BREAKING changeset. Worth refreshing so anyone reading the release history isn't misled. Validated (fetched raw files at 1e2a52a): Read only: the |
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DWrXQsPLEpjGyPxXxv8Yhc
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DWrXQsPLEpjGyPxXxv8Yhc
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c4ba6ec625
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| }, | ||
| "peerDependencies": { | ||
| "@data-client/react": "^0.12.15 || ^0.13.0 || ^0.14.0 || ^0.15.0 || ^0.16.0 || ^0.17.0 || ^0.18.0", | ||
| "@data-client/react": "^0.15.0 || ^0.16.0 || ^0.17.0 || ^0.18.0", |
There was a problem hiding this comment.
Raise the React 0.15 peer floor to 0.15.3
When a CommonJS/Jest consumer installs one of the permitted @data-client/react versions 0.15.0–0.15.2, the new imports of @data-client/react/mock fail with ESM parsing errors. The repository's React changelog explicitly records CommonJS support for the /mock subpath as a 0.15.3 fix (packages/react/CHANGELOG.md lines 293–299), whereas the previous @data-client/test bundle did not depend on that subpath. Set the peer floor to ^0.15.3 and update the migration text accordingly.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed from the published tarballs: @data-client/react@0.15.0–0.15.2 export ./mock with only types/default (ESM), and require: ./dist/mock.js first appears in 0.15.3. This predates the PR (the old dist/index.js already required @data-client/react/mock for mockInitialState), but the stated floor should be accurate. Since this PR is in the merge queue, the follow-up PR will raise the peer to ^0.15.3 and update the changeset and migration text to say 0.15.3.
Generated by Claude Code
| 'use client'; | ||
| import { ControllerContext, useController } from '@data-client/react'; | ||
| import { MockController } from '@data-client/react/mock'; | ||
| import type { MockProps } from '@data-client/react/mock'; |
There was a problem hiding this comment.
Preserve the current fixture argument types with older peers
When the new @data-client/test is paired with any still-permitted 0.15–0.18 React release, MockResolverProps now inherits that older release's MockProps and fixture declarations rather than this release's declarations. In particular, the current release's .changeset/fixture-args-readonly.md promises that args: [...] as const is accepted, but that fix landed after 0.18.1; with an older peer the same fixture is rejected again. Either require the matching React release or keep a local type façade so @data-client/test's advertised types do not vary with the installed peer.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
True: with @data-client/test 0.19 and @data-client/react 0.18.x, fixture types come from react 0.18, so args: [...] as const (.changeset/fixture-args-readonly.md) only type-checks once react is upgraded too. A local type façade would bring back the duplicate this PR removes. The packages release linked, and both the changeset and the v0.19 migration guide tell users to upgrade @data-client/react with @data-client/test. The alternative is narrowing the peer to the matching release, and I've put that choice to the maintainer rather than build anything here.
Generated by Claude Code
| ErrorFixture, | ||
| Interceptor, | ||
| } from './fixtureTypes.js'; | ||
| } from '@data-client/react/mock'; |
There was a problem hiding this comment.
Declare the endpoint package required by re-exported types
In a project that installs only the documented @data-client/test and @data-client/react packages, resolving this new type re-export reaches @data-client/core/mock, whose fixtureTypes.d.ts imports @data-client/endpoint. Neither @data-client/test, React, Core, nor Core's Normalizr dependency installs Endpoint as a production dependency, so such consumers now get Cannot find module '@data-client/endpoint' during type checking; the previous local fixture declarations imported these types from the installed React peer instead. Add the required package dependency/peer or avoid exposing a declaration with an undeclared transitive import.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed. packages/core/src/mock/fixtureTypes.ts imports EndpointInterface/ResolveType from @data-client/endpoint, which @data-client/core doesn't depend on. This was already reachable before this PR, though: mockInitialState(fixtures: Fixture[]) from both @data-client/test and @data-client/react/mock resolves the same core/mock/fixtureTypes.d.ts. The root fix belongs in core: import those types from '../index.js', which core already re-exports, the way the deleted test copy did. This PR is already in the merge queue, so that one-line fix will land in a follow-up PR right after it merges.
Generated by Claude Code
Requested by Nathaniel · project thread
Motivation
Before:
@data-client/testshipped its own copies of the fixture types,MockController,collapseFixtureandcreateFixtureMap. They were byte-identical topackages/core/src/mock/*except for the import source, so every fix had to land twice, and any drift would give users two incompatibleFixturetypes. Its peer range also listed@data-client/react0.12–0.14, versions that never had the@data-client/react/mockentry it imports.After:
@data-client/testimports and re-exports all of these from@data-client/react/mock, and breaking: it requires@data-client/react0.15 or later. Its public exports are otherwise unchanged.Solution
fixtureTypes.ts,mockTypes.ts,MockController.ts,collapseFixture.ts,createFixtureMap.tsxandmockState.ts. Everything now imports from@data-client/react/mock, which stays external in the rollup bundle.^0.15.0, released as a BREAKING minor and added to the v0.19 blog summary and migration guide.Changeset:
Agent impact review found no skill or example to update, and no realistic agent task, so the changeset has a
no-agent-impact.jsonentry.Verified:
yarn ci:build:types, the react/rest/core-mock jest suites (649 passed),yarn check:doc-examples react(277 pass),yarn copy:websitetypes, and the exported names of@data-client/test's declarations, which are the same before and after.🤖 Generated with Claude Code
https://claude.ai/code/session_01DWrXQsPLEpjGyPxXxv8Yhc
Note
Medium Risk
Breaking peer range affects consumers on @data-client/react 0.14 or older; runtime behavior for upgraded pairs should match the removed duplicate implementation.
Overview
@data-client/testnow delegates mocking to@data-client/react/mockinstead of maintaining duplicateMockController, fixture types, and helper modules. Public exports (Fixture,Interceptor,mockInitialState, etc.) are unchanged but are re-exported from@data-client/react/mock, so types align with imports from either package.Breaking: the
@data-client/reactpeer dependency floor is raised to ^0.15.0 (0.12–0.14 dropped) because the mock entry shipped in 0.15. A changeset, v0.19 blog migration section, playground editor types, and an agentno-agent-impactnote document the upgrade path.Reviewed by Cursor Bugbot for commit c4ba6ec. Bugbot is set up for automated code reviews on this repo. Configure here.