A high-performance, lightweight API load testing tool built with Node.js and TypeScript. Stress-test GET and POST endpoints with configurable RPS and duration, featuring detailed logging and recursive data generation.
- Asynchronous Execution: Leverages Node.js event loop and
axiosfor efficient concurrent request handling. - Configurable Load: Easily set
requestsPerSecondanddurationInSecondsfor tailored stress testing. - Detailed Logging: All failed requests and (optionally) successful ones are logged to the
results/directory with timing and response bodies. - Robust Request Tracking: Ensures accurate reporting of sent vs. completed requests, even under heavy failure rates.
- Type-Safe Dynamic Data: Uses a recursive data generator for complex POST request payloads.
- Modern Stack: Developed with TypeScript 5+, ESM, and strict linting rules.
- Node.js: v18.0.0 or higher
- npm: v9.0.0 or higher
-
Clone the Repository:
git clone https://github.com/Alike73/API-TESTER.git cd api-tester -
Install Dependencies: Ensure you have Node.js installed, then run:
npm install
-
Configure Environment: Create a
.envfile in the root directory:BASE_URL=https://api.example.com/endpoint TOKEN=your_bearer_token_here
You can execute the tests directly using tsx (no pre-compilation required):
Used for performance testing read endpoints with optional query parameters.
npx tsx testGet.tsUsed for stress testing write endpoints with dynamic payload generation.
npx tsx testPost.tsTest summaries and failure logs are saved in the results/ directory:
results/results.txt: Output from GET tests.results/post_results.txt: Output from POST tests.
- TypeScript: Strict type checking enforced (
noImplicitAny: true, etc.). - ESLint: Configured with
typescript-eslintfor consistent code quality. - Error Handling: Uses
axios.isAxiosErrortype guards for precise error reporting.
- RPS Throttling: Uses
setIntervalwith internal loops to maintain a steady request rate. - Graceful Completion: Uses
finallyblocks to track request completion, ensuring final reports are only generated after all pending requests are settled. - Log Management: Separates results by test type and prevents log bloat by allowing optional logging of successful responses.
Type Checking:
npx tsc --noEmitLinting:
npx eslint .Senior QA & TypeScript Recommendation: Always verify your .env configuration against a staging environment before running high RPS tests to avoid unintentional API rate limiting or service disruption.
