PromiseMe
Very minimalistic testing framework.
Installation
npm install promise-me-framework
Usage
const describe = core;let test =;let scope = {};scope;
Basics
Main concept is to use promise chains. Like this:
;
Although it's not "real" code but you've got the idea.
Now here is simple testing scenario:
const describe = core;// declaring scenario{}i: 0// declaring step// handling scenario results and errors;
And lets make it more modular:
// declaring steplet Increment =;let scenarioOptions = {};let scenarioScope = increment: 0;// declaring scenarioscenarioOptionsscenarioScope// handling scenario results and errors;
Asynchronous steps
We can make our simple scenario asynchronous.
In order to do so we have to return promise instead of $scope:
// declaring steplet Increment =;
Defenitions options
parameters
We can pass parameters to step like this:
And in order to access it within step definition we have to use params property of context:
let Increment =;
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 =;
providers
Also we can provide some data to context using providers
let browser = ;let browser;let myTest = ;
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 = ;let After = ;let Action = ;let Prepare = ;let Continue = ;// declaring grouplet Group =;
and then use as regular step defenition
Alias module
as you can see we have to invoke description with scope object as parameter in order to create promise chain
// declaring grouplet Group =;
it's perfectly fuctional but not quite clear what is happening here
we can fix this using alias module like so:
const alias = alias;let given = alias;let Group =;
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 = parallel;
and use like this:
note that all descriptions will share same scope object
parallel method will pass down an array of resolved promises, or will throw a rejection