Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
HTTPtestify
✓ import HTTPtestify from 'http-testify';
✗ const HTTPtestify = require('http-testify');
While the library's `README` uses `require` for CommonJS, modern Node.js applications and TypeScript projects should prefer the ESM `import` syntax. The package is designed with TypeScript in mind, ensuring proper type inference with `import`.
request
✓ const server = HTTPtestify.request(app);
✗ import { request } from 'http-testify';
`request` is a method on the default-imported `HTTPtestify` object, used to initialize a test server instance. It is not a named export that can be destructured directly from the package.
get
✓ server.get('/api/data').then(...);
✗ HTTPtestify.get('/api/data').then(...);
HTTP methods like `get`, `post`, `put`, etc., are invoked on the `server` instance returned by `HTTPtestify.request(app)`, not directly on the main `HTTPtestify` object.
Demonstrates how to set up `http-testify` with a simple Express server, make GET and POST requests, and execute parallel requests, logging their responses.
import HTTPtestify from 'http-testify';
import express from 'express'; // Common framework for HTTP APIs
// 1. Create a minimal Express app instance for testing
const app = express();
app.use(express.json()); // Enable JSON body parsing for POST requests
// Define a simple GET endpoint
app.get('/api/status', (req, res) => {
res.status(200).json({ status: 'ok', version: '1.0' });
});
// Define a simple POST endpoint
app.post('/api/submit', (req, res) => {
const data = req.body;
res.status(201).json({ message: 'Data received', received: data });
});
// 2. Initialize HTTPtestify with the app instance
const server = HTTPtestify.request(app);
// 3. Define an async test function
async function runExampleTests() {
try {
// Perform a GET request
const getResponse = await server.get('/api/status');
console.log('GET /api/status Status:', getResponse.status); // Expected: 200
console.log('GET /api/status Data:', getResponse.data); // Expected: { status: 'ok', version: '1.0' }
// Perform a POST request with a JSON body
const postResponse = await server.post('/api/submit', { item: 'widget', quantity: 5 });
console.log('POST /api/submit Status:', postResponse.status); // Expected: 201
console.log('POST /api/submit Data:', postResponse.data); // Expected: { message: 'Data received', received: { item: 'widget', quantity: 5 } }
// Demonstrate parallel GET requests
const [res1, res2] = await server.all((instance) => [
instance.get('/api/status'),
instance.get('/api/status')
]);
console.log('Parallel Requests Results:', res1.status, res2.status);
console.log('\nAll example tests completed successfully!');
} catch (error) {
console.error('An error occurred during tests:', error);
}
}
runExampleTests();
Errors
Common errors & fixes
TypeError: HTTPtestify.request is not a function
Attempting to destructure `request` as a named import (e.g., `import { request } from 'http-testify'`) when it's a method on the default export.
fixImport the default `HTTPtestify` object and then call `HTTPtestify.request(app)`.
AssertionError: Expected status 200, got 404
The tested API endpoint returned an unexpected HTTP status code, often due to an incorrect route, missing handler, or server-side error.
fixVerify the endpoint path, HTTP method, and server-side route definitions. Check server logs for internal errors during the request.
UnhandledPromiseRejectionWarning: This error originated either by throwing an error inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().
An `http-testify` operation (or subsequent assertion) rejected a Promise, and the rejection was not caught by an `await` within a `try/catch` block or a `.catch()` handler.
fixWrap asynchronous test code in `try...catch` blocks, or ensure all Promises are handled with `.catch()` to log or assert on errors explicitly.
Audit
Dependencies
No dependency data recorded yet.