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

restwalker

v0.2.0

Published

HATOAS Service Testing

Downloads

25

Readme

Build Status Test Coverage Code Climate Dependency Status

restwalker

HATEOAS Integration Testing

Restwalker is a tool for integration testing RESTFUL services with HATEOAS hyperlinking. It uses a DSL to describe the traversal of services via rel names.

The Service Walker

The service walker accepts a series of commands, which may be strings, functions, or arrays, and interacts with a RESTful services using the commands.

invoke - Invokes a RESTful interation sequence.

walker.invoke(commmands, context)

  • commands (array of ScriptCommand, required) - The integration testing commands to run in order.
    • function - When the item is a function, it is executed using context as the this context.
    • string - When the item is a string, a RESTful interaction is parsed using the DSL and executed.
    • array - When the item is an array of strings, RESTful interactions are executed in parallel.
  • context (object, optional, default={}) - The context object to associate with the interaction script.

The DSL

<path> <commands>

path

The path describes a rel-based route to a specific invocation on a resource.

<pathitem>.<pathitem>.<pathitem>... A path must start with the name of a proprety name (resolved on the context object), or root, which represents the service root. Path items are delimited by ..

pathitem

<rel><qualifier> Each path item contains a rel-name to follow and any qualifiers to apply to the invocation. The following qualifiers are recognized:

  • query-argument qualifier - Applies a Query Argument to the invocation. ${<query-argument>}. e.g. root.view_list${itemCount=100}
  • array indexer qualifier - Assumes the result of an invocation is a collection. The result of the traversal step is the item at the specified index. [index] e.g. root.view_list[1]

commands

Commmands describe interactions with the result of service invocations.

Command Types

  • with - with <propertyName> These commands use the value of propertyName on the context object to invoke an endpoint that accepts a payload. e.g. root.create_listing with listingData
  • as - as <propertyName These commands populate the value of propertyName on the context object as the result of the service invocation. e.g. root.view_profile as profile
  • emits - emits <statusCode> - Performs an assertion that the service emits a status code as the result of an invocation. e.g. root.view_list[0].delete emits 204

examples

var script = [
   'root.login with credentials as user'
   'user.view_profile as profile'
   function() { expect(profile.password).to.be.undefined; }
   'user.delete emits 204'
];
var context = { username: 'mr_test', password: 'derp' }
walker.invoke(script, context);