parcae

0.0.1 • Public • Published

Actions Status

parcae
parcae
Programmatically step through asynchronous code during test

Introduction

parcae is a tiny utility allowing you to programmatically step through asynchronous code during test.

Some example where parcae can be handy:

  • Test complex loading state on a user interface
  • Reproduce race conditions
  • Test any function containing non-trivial asynchronous logic

Installation

npm install --save parcae

import createFutures from "parcae"

How to use

Initialize the utility

const futures = createFutures()

mock the asynchronous functions you want to control making them return

futures.predict("aKey")

make a function resolve and await for it by invoking

await futures.resolve("aKey", aResult)

otherwise, make a function reject and await for it by invoking

await futures.reject("aKey", anError)

Examples

Basic example

UI example

Package Sidebar

Install

npm i parcae

Weekly Downloads

2

Version

0.0.1

License

MIT

Unpacked Size

33.3 kB

Total Files

26

Last publish

Collaborators

  • marcellomontemagno