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 🙏

© 2025 – Pkg Stats / Ryan Hefner

promise-me-framework

v1.4.1

Published

minimalistic testing framework

Readme

PromiseMe

Very minimalistic testing framework.

Installation

    npm install promise-me-framework

Usage

    const {describe} = require('promise-me-framework').core;

    let test = describe('my test\'s name', function({scope}) {
        console.log('hello');
        return scope;
    });

    let scope = {};

    test()(scope)
        .then(() => console.log('done'));

Basics

Main concept is to use promise chains. Like this:

given(LoginFeature(options), scope)
    .then(OpenPage('https://mycoolapp.com'))
    .then(FillInput({
        id: 'login',
        value: 'tester'
    }))
    .then(FillInput({
        id: 'password',
        value: getPassword('tester')
    }))
    .then(ClickButton('login'))
    .then(WaitForTitle('Welcome!'))
    .then(ReportSucces)
    .catch(ReportFailure);

Although it's not "real" code but you've got the idea.

Now here is simple testing scenario:

const {describe} = require('promise-me-framework').core;

// declaring scenario
describe('scenario', ({scope}) => scope)({})({i: 0})

    // declaring step
    .then(describe('i++', ({scope}) => {
        scope.i++;

        return scope;
     })())

     // handling scenario results and errors
    .then(() => console.log('done'))
    .catch(({error}) => console.log(error));

And lets make it more modular:

// declaring step
let Increment = describe('i++', ({scope}) => {  
    scope.i++;

    return scope;
});

let scenarioOptions = {};
let scenarioScope = {increment: 0};

// declaring scenario
describe('scenario', ({scope}) => scope)(scenarioOptions)(scenarioScope)
    .then(Increment())

    // handling scenario results and errors
    .then(() => console.log('done'))
    .catch(({error}) => console.log(error));

Asynchronous steps

We can make our simple scenario asynchronous.

In order to do so we have to return promise instead of $scope:

// declaring step
let Increment = describe('i++', ({scope}) => {  
    return new Promise(function(resolve, reject) {
        setTimeout(() => {
            scope.i++;
            resolve(scope);
        }, 2000);
    });
});

Defenitions options

parameters

We can pass parameters to step like this:

    .then(Increment(10))

And in order to access it within step definition we have to use params property of context:

let Increment = describe('i++', ({scope, params}) => {  
    scope.i += params;
});

Pretty much everything could be passed as a parameter to a step.

name

We can access description name using name property of context.

let Increment = describe('my description', ({name}) => {  
    console.log(name); // prints 'my description'
});

providers

Also we can provide some data to context using providers

let browser = getBrowser();
let openUrl = ({params, browser}) => browser.url(params);

let myTest = describe('open url', openUrl, {browser});

Note that provider will be accessible only in context of description where it was specified and won't be passed down unless it's done explicitly

Groups

We can also group steps like this:

let Before = describe('before', doSmthBefore);
let After = describe('after', doSmthAfter);
let Action = describe('action', performaction);
let Prepare = describe('prepare', doPreparations);
let Continue = describe('continue', doSmthElse);

// declaring group
let Group = describe('group', ({scope}) => {
    return Before()(scope)
        .then(Action())
        .then(After());
});

and then use as regular step defenition

.then(Prepare())
.then(Group())
.then(Continue())

Alias module

as you can see we have to invoke description with scope object as parameter in order to create promise chain

// declaring group
let Group = describe('group', ({scope}) => {
    return Before()(scope)
        .then(Action())
        .then(After());
});

it's perfectly fuctional but not quite clear what is happening here

we can fix this using alias module like so:

const {alias} = require('promise-me-framework').alias;

let given = alias;
let Group = describe('group', ({scope}) => {
    return given(Before(), scope)
        .then(Action())
        .then(After());
});

now group description can be red almost like plain english

Parallel module

we can also execute steps in parallel using paralle module

connect it like so:

const {parallel} = require('promise-me-framework').parallel;

and use like this:

.then(parallel(
    actionOne('some parameter'),
    actionTwo(),
    actionThree([1,2,3])
))
.then(({scope}) => someActions(scope))

note that all descriptions will share same scope object

parallel method will pass down an array of resolved promises, or will throw a rejection