Skip to content

pkg(test)!: Re-export mock utilities from @data-client/react/mock - #4414

Merged
ntucker merged 4 commits into
masterfrom
claude/project-thread-r5cdz6
Oct 19, 2026
Merged

ntucker merged 4 commits into
masterfrom
claude/project-thread-r5cdz6

Conversation

@ntucker

@ntucker ntucker commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Nathaniel · project thread

Motivation

Before: @data-client/test shipped its own copies of the fixture types, MockController, collapseFixture and createFixtureMap. They were byte-identical to packages/core/src/mock/* except for the import source, so every fix had to land twice, and any drift would give users two incompatible Fixture types. Its peer range also listed @data-client/react 0.12–0.14, versions that never had the @data-client/react/mock entry it imports.

After: @data-client/test imports and re-exports all of these from @data-client/react/mock, and breaking: it requires @data-client/react 0.15 or later. Its public exports are otherwise unchanged.

Solution

  • Deleted fixtureTypes.ts, mockTypes.ts, MockController.ts, collapseFixture.ts, createFixtureMap.tsx and mockState.ts. Everything now imports from @data-client/react/mock, which stays external in the rollup bundle.
  • Peer floor raised to ^0.15.0, released as a BREAKING minor and added to the v0.19 blog summary and migration guide.
  • Regenerated the website editor types.

Changeset:

BREAKING: `@data-client/test` requires `@data-client/react` 0.15 or later

Support for `@data-client/react` 0.12 through 0.14 is dropped. Upgrade `@data-client/react` along with
`@data-client/test`.
- "@data-client/react": "^0.14.0",
+ "@data-client/react": "^0.19.0",

Agent impact review found no skill or example to update, and no realistic agent task, so the changeset has a no-agent-impact.json entry.

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/test now delegates mocking to @data-client/react/mock instead of maintaining duplicate MockController, 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/react peer 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 agent no-agent-impact note document the upgrade path.

Reviewed by Cursor Bugbot for commit c4ba6ec. Bugbot is set up for automated code reviews on this repo. Configure here.

@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-bot

changeset-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c4ba6ec

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@data-client/test Minor

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

@ntucker ntucker self-assigned this Oct 19, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T17:22:01.706463Z c4ba6ec New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

ntucker commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

Staff engineer (Cursor agent): LGTM at 695337a. No change requested and no follow-up needed.

This is the right direction: @data-client/core/mock becomes the one source for MockController, the fixture types, collapseFixture and createFixtureMap, and @data-client/test becomes a thin layer over it. It removes a fork that would otherwise drift, and gives users one Fixture type instead of two look-alikes.

What I actually checked:

  • On npm, @data-client/react@0.15.0, 0.16.0 and 0.18.2 all have lib/mock/index.d.ts as export * from '@data-client/core/mock'. @data-client/core@0.15.0's mock entry already exports MockController, MockProps, every fixture type re-exported here, and mockInitialState. So the new ^0.15.0 floor holds for every version in range.
  • The published @data-client/core@0.15.0 lib/mock/MockController.js matches the deleted packages/test/src/MockController.ts in behavior (fetchResponse interceptors, function delay, delayCollapse, the _dispatch fallback). On master, packages/core/src/mock/MockController.ts is the same source. Users on any react version in the new range keep the same runtime behavior.
  • In packages/test/rollup.config.mjs, isExternal uses id.startsWith(dep) over the peer deps, so @data-client/react/mock stays external and isn't re-bundled.
  • At the head tree, the only remaining copies of these files are in packages/core/src/mock/ (plus vue's one-line mockState re-export). The regenerated playground test.d.ts imports @data-client/core/mock, which exists in editor-types/@data-client/core/mock.d.ts, the same pattern vue/test.d.ts already uses.

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 react version is the correct coupling, since runtime behavior already followed it through mockState and now does for MockController too. With linked releases, the skew case is small. One note, not new to this PR: the react 0.15.0 through 0.15.6 ./mock export has no require condition (0.15.7 added dist/mock.js). The CJS dist/index.js already required @data-client/react/mock for mockInitialState before this change, so exposure there is unchanged.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Docs preview: https://docs-site-pr-4414-data-client.vercel.app

Built from c4ba6ec merged into master (this build).

@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.37%. Comparing base (b475613) to head (c4ba6ec).
⚠️ Report is 3 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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
@ntucker ntucker changed the title pkg(test): Re-export mock utilities from @data-client/react/mock pkg(test)!: Re-export mock utilities from @data-client/react/mock Oct 19, 2026

ntucker commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

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 plans/next-breaking-release.md.

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): .changeset/config.json links @data-client/test with react and the others, and test is at 0.18.0, so minor lands it on 0.19.0 alongside react. The new blog section's anchor #test-react-0.15 matches the summary link. The "install command above" it points to is the PkgTabs line that upgrades both @data-client/react@^0.19.0 and @data-client/test@^0.19.0, so the migration advice holds.

Read only: the no-agent-impact.json entry and the changeset wording.

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Merged via the queue into master with commit 38acf12 Oct 19, 2026
32 checks passed
@ntucker
ntucker deleted the claude/project-thread-r5cdz6 branch October 19, 2026 17:24

This branch was successfully deployed

1 active deployment
docs-preview — c4ba6ec6 Deployed Oct 19, 2026 by ntucker via docs deploy #3459
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants