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

parrot-friendly

v5.2.1

Published

BDD syntax for writing Parrot scenarios.

Downloads

2,379

Readme

parrot-friendly is a helper library that allows you to write scenarios using a more declarative syntax. Based on the behavior driven development (BDD) syntax of libraries such as Jasmine and Mocha, parrot-friendly provides describe, it, and other methods to construct your scenarios object.

Example

import { describe, it, get } from 'parrot-friendly';

const scenarios = describe('Ship Log', () => {
  it('should display the ship log', () => {
    get('/ship_log')
      .response(require('./mocks/shipLog.json'))
      .delay(1200);
  });

  it('should show an error', () => {
    get('/ship_log').status(500);
  });
});

export default scenarios;

API

describe(description, scenarioDefinitions)

Returns a scenarios object based on the scenarioDefinitions declared.

Arguments

  • description (String): Scenarios object description. Currently this is not used internally but supported to provide a more common API.
  • scenarioDefinitions (Function): Function that will define scenarios when invoked.

it(description, mockDefinitions)

Adds a scenario with key description to the scenarios object.

Arugments

  • description (String): Scenario description that will be used as a key to identify the scenario. Must be unique to a scenarios object.
  • mockDefinitions: (Function): Function that will define mock objects when invoked.

mock(mockDefinition)

Creates a mock for a HTTP request where mockDefinition is the entire mock object. This can be used in place of chaining methods such as query and delay, or to provide custom mock handling with a function.

Arguments

  • mockDefinition (Object or Function): Mock object with request and response keys or mock function.

request(requestDefinition)

Creates a mock for a HTTP request where requestDefinition is the entire request object. Can be used in place of chaining request methods such as query or to provide a custom matching function.

Arguments

  • requestDefinition (Object or Function): Request object to be matched against or request function returning true for a match and false for a miss.

METHOD(path)

Creates a mock for a HTTP request where METHOD is one of get, head, post, put, del, connect, options, patch.

del is used in place of delete as delete is a JavaScript reserved word.

Arguments

  • path (String): Path matcher string. May include route params.

Methods

.query(query)

Matches against the query object provided.

.headers(headers)

Matches against the headers object provided

.response(resource)

Responds with the resource provided.

.delay(amount)

Delays the response for amount of milliseconds.

.status(code)

Responds with a code status code.

graphql(path, schema, mocks)

Creates a mock for your GraphQL endpoint.

Arguments

  • path (String): Path of your GraphQL endpoint.
  • schema (String): GraphQL schema string.
  • mocks (Object): Object describing your mocking logic that is passed to graphql-tools mockServer.