New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rapid-check

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rapid-check

Yet another implementation of property based testing framework with support for async properties.

  • 0.2.0
  • npm
  • Socket score

Version published
Weekly downloads
7
Maintainers
1
Weekly downloads
 
Created
Source

rapid-check CircleCI

Yet another implementation of property based testing framework with support for async properties.

Installation

npm install rapid-check

Usage

Works with any testing framework, here's example using jest:

it('tests Set.has function', () => {
  const s = new Set([1, 2, 3])
  const prop = (v) => s.has(v)
  const [result, _] = forAll(choose(1, 3), prop)
  expect(result).toBe(true)
})

it('tests async Set.has function', async () => {
  const s = new Set([1, 2, 3])
  const prop = (v) => Promise.resolve(s.has(v))
  const [result, _] = await asyncForAll(choose(1, 3), prop)
  expect(result).toBe(true)
})

Generators

constantly(any)

sample(constantly(4))
// [4, 4, 4, 4, ...]

choose(min, max)

sample(choose(1, 3))
// [2, 1, 3, 1, ...]

bool

sample(bool)
// [true, true, false, true, ...]

int

sample(int)
// [0, 1, -2, 3, ...]

uint

sample(uint)
// [0, 1, 0, 3, ...]

tuple(...gens)

sample(tuple(uint, uint))
// [[0, 0], [1, 0], [1, 2], [0, 1], ...]

array(gen, min, max)

sample(array(uint, 1, 3))
// [[0], [1], [2, 0], [1, 1], [0], [0, 3, 3], ...]

oneOf(...gens)

sample(oneOf(bool, uint))
// [true, 1, 2, false, ...]

fmap(f, gen)

Where f: a -> b

const negate = (n) => -n
sample(fmap(negate, uint))
// [0, -1, -1, -3, ...]

mbind(f, gen)

Where f: a -> Gen b

const f = (n) => ap(tuple, repeat(bool, n))
sample(mbind(f, uint))
// [[], [true], [false, false], [false], ... [true, false, false, true, false], [false]]

FAQs

Package last updated on 17 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc