Skip to content

test: use Undici matching version bundled with Node.js - #970

Merged
paulrobertlloyd merged 1 commit into
mainfrom
test/undici
Sep 26, 2026
Merged

paulrobertlloyd merged 1 commit into
mainfrom
test/undici

Conversation

@paulrobertlloyd

Copy link
Copy Markdown
Collaborator

Tests mocked HTTP requests using a MockAgent from undici@8, but CI runs on Node.js 24, whose built-in fetch() is powered by Undici 7. Node.js doesn’t expose its bundled Undici, and dispatchers aren’t compatible across major versions (see nodejs/undici#5341), so tests were passing by luck rather than design.

Changes

  • Adds @indiekit-test/undici helper, which installs undici@7 and undici@8 as aliases and re-exports MockAgent, setGlobalDispatcher etc. from whichever matches process.versions.undici
  • Updates mock agent helpers and tests to import from this helper, and removes the direct undici dependency
  • Adds ESLint rule preventing undici from being imported directly
  • Adds smoke tests that check the major versions match, and that built-in fetch() intercepted by MockAgent keeps response headers and decodes compressed bodies (the symptoms of a mismatch)
  • Runs tests on Node.js 24 and 26

Notes

When a future Node.js release bundles a new major version of Undici, add an alias to helpers/undici/package.json. Until then, the helper throws with a message explaining what to do.

@paulrobertlloyd paulrobertlloyd added the dependencies Pull requests that update a dependency file label Sep 26, 2026
@paulrobertlloyd
paulrobertlloyd merged commit 466cf32 into main Sep 26, 2026
2 checks passed
@paulrobertlloyd
paulrobertlloyd deleted the test/undici branch September 26, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant