fast-check-bun-test
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

fast-check-bun-test

NPM Version NPM License GitHub Actions Workflow Status

fast-check-bun-test is a fork of @fast-check/vitest, adapted to integrate property-based testing with bun:test. It leverages the power of fast-check to generate random inputs and verify your code’s behavior under a wide range of scenarios, all within Bun’s lightweight and fast testing framework.

Installation

Install fast-check-bun-test as a development dependency. Note that the package requires fast-check as a peer dependency, so you must install it separately.

bun add --dev fast-check-bun-test

Usage

Here’s an example of how to use fast-check-bun-test to test a simple property:

import { test, fc } from 'fast-check-bun-test';

// Example: Verify that b is a substring of a + b + c for all strings a, b, c
test.prop([fc.string(), fc.string(), fc.string()])(
  'should detect the substring',
  (a, b, c) => {
    return (a + b + c).includes(b);
  }
);

// Same property using named values for clarity
test.prop({ a: fc.string(), b: fc.string(), c: fc.string() })(
  'should detect the substring',
  ({ a, b, c }) => {
    return (a + b + c).includes(b);
  }
);

This example demonstrates how fast-check-bun-test generates random strings to confirm that concatenation preserves substring inclusion. For more advanced usage, visit the fast-check documentation.

Package Sidebar

Install

npm i fast-check-bun-test

Weekly Downloads

28

Version

0.1.2

License

MIT

Unpacked Size

11 kB

Total Files

5

Last publish

Collaborators

  • shuntksh