npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

http-testify

v1.0.3

Published

A Node.js library for testing HTTP servers.

Downloads

49

Readme

HTTPtestify

HTTPtestify is a versatile library for testing HTTP APIs in Node.js environments. It provides a promise-based API inspired by Axios, allowing you to make HTTP requests, perform assertions on responses, and conduct integration testing with ease.

Features

  • Promise-Based API: Enjoy a promise-based API that lets you make HTTP requests using async/await and promise chaining, promoting clean and readable code.
  • Integration Testing: Seamlessly perform integration tests on your HTTP APIs to ensure they function as intended.
  • HTTP Request Methods: Support for various HTTP request methods, including GET, POST, PUT, DELETE, and more, allowing interaction with diverse API endpoints.
  • Request Customization: Tailor your requests with ease, adjusting headers, query parameters, and request bodies as required.
  • Response Assertions: Utilize chainable methods to validate different aspects of responses, such as status codes, headers, and response data.
  • Chaining Requests: Seamlessly chain requests together, enabling complex testing scenarios with dependent requests.
  • Parallel Requests (All): Perform multiple requests simultaneously using the all method, receiving an array of responses when all requests complete.
  • Parallel Requests (Race): Race multiple requests with the race method, resolving with the response of the first completed request.
  • Parallel Requests (AllSettled): Perform parallel requests using allSettled, resolving with an array of response states, including both successful responses and errors.
  • Custom Port: Set a custom port between 1 and 65535 for the mock server instance, allowing flexibility in defining the server's listening port.
  • Cancellation: Cancel pending requests when they're no longer needed, preventing unnecessary processing.
  • Concurrent Requests: Boost performance by sending multiple requests concurrently.
  • Error Handling: Automatically handle network errors and HTTP errors, providing comprehensive error information.
  • Proxy Support: Seamlessly navigate proxies with configuration options for smoother testing.
  • JSON and XML Handling: Automatically parse JSON responses and optionally support XML responses for easy assertion and testing.
  • Download and Upload Progress: Monitor progress when dealing with large files, ensuring efficient request handling.
  • Cookie Handling: Simplify authentication and stateful API testing with methods to manage and assert cookies.
  • Session Persistence: Maintain session continuity between requests, crucial for scenarios that involve sequential interactions.

Installation

You can install HTTPtestify using npm:

npm install http-testify

Usage

Making HTTP Requests

To make HTTP requests using HTTPtestify, you can follow this example:

const HTTPtestify = require("http-testify");
const app = require("./your-app"); // Replace with your actual app instance

// Create a mock server instance with the target app and port
const server = HTTPtestify.request(app);

// Make a GET request to a specific route
server
  .get("/api/data")
  .then((response) => {
    console.log("Response from /api/data:", response.data);
  })
  .catch((error) => {
    console.error("Error occurred:", error);
  });

Parallel Requests with all

You can perform multiple requests in parallel using the all method:

// Use promise-based operations
const promises = server
  .all((instance) => [instance.get("/api/data1"), instance.get("/api/data2")])
  .then((responses) => {
    console.log("All responses:", responses);
  })
  .catch((error) => {
    console.error("An error occurred:", error);
  });

Docs

HTTPtestify provides a variety of methods to facilitate testing HTTP interactions. Check the documentation for detailed information.

Contributing

Contributions to HTTPtestify are welcome! Feel free to submit issues and pull requests on the GitHub repository.

Donate

Please consider donating if you think HTTPtestify is helpful to you or that my work is valuable. I am happy if you can help me buy a cup of coffee. ❤️

License

This project is licensed under theMIT License