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

apparition

v1.0.0

Published

A collection of test helpers.

Downloads

3

Readme

apparition

Build Status

A collection of test helpers.

Overview

npm install apparition

Properties

The Properties helper provides a managed way to make changes to an object's properties and then roll those changes back at a later point.

Every method other than get() returns a chainable reference to the properties object.

new Properties (subject)

| parameter | description | |-----------|-----------------------------------------------| | subject | the object managed by the helper |

Initializes a new Properties helper instance.

properties.delete (name)

| parameter | description | |-----------|------------------------------------| | name | the name of the property to delete |

returns a chainable self reference

Unsets a specified object property.

properties.get (name)

| parameter | description | |-----------|--------------------------------------| | name | the name of the property to retrieve |

returns the value of the property or undefined if not set.

Retrieves the current value of a specified property.

properties.restore ()

Reverts all changes to the object since the last call to restore().

returns a chainable self reference

properties.set (name, [value])

| parameter | description | |-----------|------------------------------------| | name | the name of the property to update | | value | optional the value to set |

returns a chainable self reference

Sets the value of a specified property. If the value is omitted, this is the same as calling delete(name).

Environment

The Environment helper provides a managed way to make changes to the process environment and then roll those changes back at a later point. This is often useful when testing code that relies on environment variables.

All operations will normalize variable names to upper case. Every method other than get() returns a chainable reference to the environment object.

Environment extends the Properties API.

new Environment()

Initializes a new Environment helper instance.

environment.delete (name)

| parameter | description | |-----------|------------------------------------| | name | the name of the variable to delete |

returns a revert function

Unsets a specified environment variable.

environment.get (name)

| parameter | description | |-----------|--------------------------------------| | name | the name of the variable to retrieve |

returns the value of the environment variable or undefined if not set.

Retrieves a specified environment variable's current value.

environment.restore ()

Reverts all changes to the environment since the last call to restore().

returns a chainable self reference

environment.set (name, [value])

| parameter | description | |-----------|------------------------------------| | name | the name of the variable to update | | value | optional the value to set |

returns a chainable self reference

Sets the value of a specified environment variable. If the value is omitted, this is the same as calling delete(name).

Request

The Request helper provides a convenience API for constructing request objects that can be injected into Hapi server instances.

All operations other that inject() return a chainable reference to the request object.

new Request (method, path)

| parameter | description | |-----------|---------------------------------------| | method | the HTTP request method to use | | path | the endpoint to submit the request to |

Instantiates a new Request helper instance. The method name is normalized to lower case.

request.header (name, value)

| parameter | description | |-----------|----------------------------------| | name | the name of the header to define | | value | the header value |

returns a chainable self reference

Defines a header value to be included with the request.

request.inject (server)

| parameter | description | |-----------|------------------------------------------------------------------| | server | the Hapi server instance that should process the request |

returns a promise that is resolved with the response object. See the Hapi API documentation for more details.

Submits the request to a server instance for processing.

request.mime (type)

| parameter | description | |-----------|-----------------------------------------| | type | the content type of the request payload |

returns a chainable self reference

Defines the MIME type of the request payload. When the MIME type is set to either application/json or application/x-www-form-urlencoded then the value passed to payload() will be encoded as that type. All other payloads are encoded as strings.

request.payload (content)

| parameter | description | |-----------|-----------------------------------------| | content | the content to include as the payload |

returns a chainable self reference

Defines a payload for the request. Objects are automatically encoded based on the content type set with mime(). It is an error to call payload() on a Request object that does not use either the post or put HTTP method.

request.user (username, password)

| parameter | description | |-----------|---------------------------------------------| | password | the password portion of the user credential | | username | the username portion of the user credential |

returns a chainable self reference

Authenticates the request object according to the HTTP Basic Auth scheme.