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

@egomobile/http-supertest

v0.7.1

Published

Sets up common and powerful test event listener for @egomobile/http-server with supertest under the hood.

Downloads

53

Readme

npm PRs Welcome

@egomobile/http-supertest

Sets up common and powerful test event listener for @egomobile/http-server with supertest under the hood.

Table of contents

Install []

Execute the following command from your project folder, where your package.json file is stored:

npm install --save @egomobile/http-supertest

Usage []

Quick example []

import createServer from "@egomobile/http-server";
import { setupTestEventListener } from "@egomobile/http-supertest";

const app = createServer();

// s. https://github.com/egomobile/node-http-server/wiki/Testing
app.controllers();

// register `test` event: https://egomobile.github.io/node-http-server/interfaces/IHttpServer.html#on
setupTestEventListener({
  server: app,
});

await app.test();

Filters []

If you defined a lot of tests and want to skip some of them, you can use EGO_TEST_FILTER environment variable.

It can hold a non-empty value, that is a Filtrex expression.

If it returns a truthy value, the underlying test will be executed.

Beside shipped-in functions and constants, the module also provides the following enhancements:

Functions:

| Signature | Description | Example | | --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | all(value, ...subStrings): bool | Checks if all substrings are part of value. | all("foo bar buzz", "bar", "buzz") | | any(value, ...subStrings): bool | Checks if at least one substring is part of value. | any("foo bar buzz", "test", "bar") | | endsWith(value, suffix): bool | Checks if a string ends with a suffix. | endsWith("Test string", " string") | | float(value): number\|false | Converts a string to a float. | float("12.3") == 12.3 | | indexOf(value): number | Returns the zero-based index of a substring inside a string, and -1 if it is not found. | indexOf("666.0", ".") == 3 | | int(value): number\|false | Converts a string to an integer. | int("10.0") == 10 | | isNaN(value, float = true): bool | Checks if a value cannot be parsed as number. | isNaN("is not a really number") | | join(sep, ...values[]): bool | Handles values as strings an join them with a separator. | join("+", "a", "b", " c") == "a+b+ c" | | norm(value): string | Normalizes a string for better comparison: creates lower case version, trims it and replace special characters like umlauts or whitespace | norm("  A tesT String: Ä    ö Ü ß ") == "a test string: ae oe ue ss" | | log(value [, returnValue = false]): any | Logs a value. | log(methodName) or methodName == "getAllUsers" | | lower(value): string | Converts string to lower case chars. | lower("ThIs Is A tEsTsTrInG") == "this is a test string" | | regex(value, pattern [, flags = "i"]): bool | Tests a string for a regular expression. | not regex(methodName, "^(ZZZ)(\\s)(-)") | | str(value): string | Converts a value to a safe string. | str(1) == "1" | | startsWith(value, prefix): bool | Checks if a string starts with a prefix. | startsWith("Test string", "Test ") | | trim(value): string | Removes leading and ending whitespace characters from a string. | trim(" Test String ") === "Test String" | | trimEnd(value): string | Removes ending whitespace characters from a string. | trimEnd(" Test String ") === " Test String" | | trimStart(value): string | Removes leading whitespace characters from a string. | trimStart(" Test String ") === "Test String " | | upper(value): string | Converts string to upper case chars. | upper("ThIs Is A tEsTsTrInG") == "THIS IS A TEST STRING" |

Constants:

| Name: type | Description | Example | | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------- | | context: string | The context in what the test is executed. | context == "controller" | | countFailure: number | The current number of failed tests. | countFailure > 0 | | description: string | The description of the test. | any(description, "foo") | | escapedQuery: string | The escaped query string. | a=foo%20bar&b=buzz | | escapedRoute: string | The escaped route of the endpoint. | escapedRoute == "/foo%20bar/buzz" | | file: string | The full path of the file. | file == "/path/to/endpoints/file/index.ts" | | group: string | The name of the current test group, which is usually the name of the controller class. | group == "MyControllerClass | | httpMethod: string | Upper case HTTP method. | httpMethod in ("POST", "GET", "PATCH", "DELETE") | | methodName: string | The name of the controller method, that is executed by the test. | methodName == "getAllUsers | | parameters: string | The JSON string of the object, with all URL parameters. | parameters == "{\"user_id\":\"foo\"}" | | query: string | The JSON string of the object, with all query parameters. | query == "{\"a\":\"foo\"}" | | route: string | The unescaped route of the endpoint. | route == "/foo bar/buzz" |

Credits []

The module makes use of:

Documentation []

The API documentation can be found here.