Repository navigation
chore(internal): resolve node-fetch to the SDK shim in resource tests - #236
Open
spicysouvlaki wants to merge 1 commit into
Open
spicysouvlaki wants to merge 1 commit into
spicysouvlaki wants to merge 1 commit into
Conversation
stlc writes every new resource test with
`import { Response } from 'node-fetch'`. Since #191 the client prefers
the native fetch on modern Node, so `asResponse()` returns the native
Response and `expect(rawResponse).toBeInstanceOf(Response)` fails
against node-fetch's class. Each new resource has turned main red until
someone patched its test by hand: webhooks, navigation policies, labels
(#232), downloads (#233).
A jest resolver now points `node-fetch` at `src/_shims/index` for files
under tests/api-resources only, which is the import those hand patches
used. tests/index.test.ts and src/_shims keep the real node-fetch, so
the fallback transport is still tested.
Measured locally on Node 24.19 with labels.test.ts switched back to the
generator's import: 4 of 9 tests fail without the resolver
("Expected constructor: Response / Received constructor: Response"),
9 of 9 pass with it. Full suite: 27 suites, 201 tests pass.
The existing hand patches stay; removing them is a separate change.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
spicysouvlaki
marked this pull request as ready for review
November 12, 2026 23:38
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.
New generated resource tests import
Responsefromnode-fetchand failtoBeInstanceOfagainst the native Response the client returns. A jest resolver maps that import to the SDK shim fortests/api-resourcesonly, so a new resource no longer turnsmainred.Test-only: nothing in the published package changes.
🤖 Generated with Claude Code