A TypeScript-friendly alternative to Supertest that uses the native Node.js WHATWG Fetch API (available since Node 18). Currently at version 2.0.0 with semantic-release based releases. Key differentiators: no dependency on superagent, avoiding @types/superagent quirks; uses native fetch for better performance and compatibility; supports both ESM and CJS; first-class TypeScript type definitions shipped with the package.
npm install supertest-fetchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates an HTTP server, wraps it with makeFetch, and tests a simple JSON response using chained assertions.
Upgrade Node to 18+ or use previous version (1.x) that used node-fetch polyfill.
Use .expectStatus() explicitly for status code checks.
Explicitly call server.listen() before tests and use makeFetch(server, {keepOpen: true}) to avoid auto-managed port assignment.Use either .expectBody() for simple assertions or manually read the response for advanced checks, not both.
Use `import { makeFetch } from 'supertest-fetch'` in an ESM module or `const { makeFetch } = require('supertest-fetch')` in CJS.Call server.listen() manually before tests and pass `{keepOpen: true}` option to makeFetch.Run `npm install supertest-fetch --save-dev` and ensure Node >= 18.