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

@unleash/client-specification

v5.1.7

Published

A collection of test specifications to guide client implementations in various languages

Downloads

561

Readme

Build

Unleash Client Specifications

Implementing a Unleash client for a specific platform can be a challenge in it's own. And we want the clients to follow specific platform and language conventions, but at the same time we want the clients to adhere to the unleash contract, and give predictable results across platforms.

This project tries to define the expected results of certain predefined set of feature toggles, using the  built-in activation strategies and with a given unleash context.

Test structure

All the tests are located in the /specifications folder.

There is an entry point for all the tests, which will include a list of all the defined specification test cases, /specifications/index.json. Clients should parse this entry-point in order to discover all specifications to run.

[
  "01-simple-examples.json",
  "02-user-with-id-strategy.json",
  "03-gradual-rollout-user-id-strategy.json",
  "04-gradual-rollout-session-id-strategy.json",
  "05-gradual-rollout-random-strategy.json",
  "06-remote-address-strategy.json",
  "07-multiple-strategies.json",
  "08-variants.json",
  "09-strategy-constraints.json",
  "10-flexible-rollout-strategy.json",
  "11-strategy-constraints-edge-cases.json",
  "12-custom-stickiness.json",
  "13-constraint-operators.json",
  "14-constraint-semver-operators.json"
  "15-global-constraints.json"
]

A Test Specifications will have the following shape:

{
    "name": "Example Test Case",
    "state": {
        "version": 1,
        "features": []
    },
    "tests": [
        {
            "description": "Unknown toggle should be disabled",
            "context": {},
            "toggleName": "Unknown.Toggle",
            "expectedResult": false
        }
    ],
    "variantTests": [
        {
            "description": "Feature with variants",
            "context": {
                "userId": "1234"
            },
            "toggleName": "Feature.Variants",
            "expectedResult": {
                "name": "variant",
                "payload": {
                    "type": "string",
                    "value": "value"
                },
                "enabled": true
                "feature_enabled": true
            }
        }
    ]
}

Fields description:

  • name - The name of the specification
  • state - The list of toggles coming from the unleash-server. Would be the same response as the client will see when requesting http://unleash-api/client/features. The state will be used for all test cases in this specification.
  • tests - The list of isEnabled tests cases to run.
    • description - Describes what this test case is testing. Suitable to output as the error message if the test case fails.
    • context - The unleash context the client should setup.
    • toggleName - The toggle name to send in to the isEnabled call in this test case.
    • expectedResult - The expected result of the isEnabled call with the given toggleName.
  • variantTests - The list of getVariant tests cases to run.
    • description - Describes what this test case is testing. Suitable to output as the error message if the test case fails.
    • context - The unleash context the client should setup.
    • toggleName - The toggle name to send in to the isEnabled call in this test case.
    • expectedResult - The expected result of the getVariant call with the given toggleName.