JSPM

fast-check-bun-test

0.1.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q39450F
  • License MIT

fast-check for bun:test

Package Exports

  • fast-check-bun-test
  • fast-check-bun-test/package.json

Readme

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.