0.0.1 • Published 3 years ago

parcae v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Actions Status

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