TestCheck.js is a JavaScript library for generative property testing, drawing inspiration from QuickCheck. It empowers developers to define program properties or assumptions that should consistently hold true, subsequently testing these properties against a large number of randomly generated input cases. A significant feature of TestCheck.js is its ability to automatically shrink failing test cases, identifying and reporting the smallest possible input that causes a property to fail, which greatly aids in debugging. The package is currently at version 1.0.0-rc.2, indicating active development towards a stable 1.0.0 release. While functioning as a testing utility rather than a complete test runner, it offers seamless integration with popular JavaScript test frameworks such as AVA, Jasmine/Jest, Mocha, and Tape through dedicated plugins. It also includes comprehensive TypeScript and Flow type definitions, supporting modern, type-safe development workflows.
npm install testcheckVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define and run a basic property test using `gen.int` and `check`, illustrating both success and failure reporting.
Consult the official API documentation (http://leebyron.com/testcheck-js/api) and the Walkthrough Guide (http://leebyron.com/testcheck-js/guide) for updated API usage and migration details.
If using a test framework, install and configure the relevant `testcheck` integration package (e.g., `ava-check`, `jasmine-check`). Otherwise, invoke `check()` directly within your testing environment.
Monitor the official GitHub repository and documentation for updates leading up to the final `1.0.0` release. Ensure your test suite has adequate coverage to detect any unexpected behavior from minor API shifts.
Ensure consistent import style: use `import { check, gen, property } from 'testcheck';` for ES Modules/TypeScript environments, or `const { check, gen, property } = require('testcheck');` for CommonJS environments.Add the necessary import statement at the top of your file: `import { check, gen, property } from 'testcheck';` (for ESM/TS) or `const { check, gen, property } = require('testcheck');` (for CommonJS).Examine the `result.shrunk.smallest` output from the `check` function to identify the minimal failing input. Debug your property function and/or the application code it tests to resolve the discrepancy.
No dependency data recorded yet.