coinobi
v0.1.1
Published
In my experience, there's no such thing as luck
Downloads
11
Maintainers
Readme
Coinobi
Deterministic and non-deterministic boolean testing utilities
"In my experience, there's no such thing as luck"
The Problem
When testing, you sometimes want some random values to avoid using the same static data in each test and avoid missing edge cases.
However, this comes with a couple of problems:
- For testing purposes you want your data to be predictable
- Sometimes randomness isn't diverse. For example, it's possible that 5 coin flips in a row all turn up heads. This is a problem if your tests rely upon at least one value being true/false.
Coinobi gives you deterministic luck by allowing you to specify patterns of returned results.
Of course, you are welcome to use this packages for non-testing scenarios
Examples
CreateCoin
createCoin
- create a coin that has flips which alternate between
true and false
import { createCoin } from 'coinobi'
const coin = createCoin()
coin.flip() // true
coin.flip() // false
coin.flip() // true
coin.flip() // false
coin.flip() // true
// ...