Registry / testing / verify-it

verify-it

JSON →
library2.4.0jsnpmunverified

verify-it is a NodeJS library designed for generating randomized property inputs and test data, intended to be used with existing test runners like `node:test`, Mocha, Jest, or Vitest. It operates by delegating test execution to the `it`/`test` and `describe` functions provided by the user's chosen test framework. The current stable version is 2.4.0. The library receives consistent updates, indicated by its recent release history, though a formal release cadence is not explicitly stated. A key differentiator is its focus on *data generation* for single-run test scenarios rather than full property-based testing that explores many permutations, ensuring each test scenario runs once with the requested randomized inputs. It provides a set of built-in generators (`Gen.string`, `Gen.object`, etc.) and allows for easy creation of custom generators. As of v2.4.0, explicit initialization via `init()` is required, deprecating the previously available global `verify` object, which enhances compatibility with various test environments that do not automatically inject globals.

npm install verify-it
INSTALL
IMPORT
SIG · VERIFY-IT
V
verify-it
testingjavascriptv2.4.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

init
import { init } from 'verify-it'
const init = require('verify-it').init
Essential for initializing the library with your chosen test framework (e.g., node:test, Mocha, Jest) since v2.4.0.
Gen
import { Gen } from 'verify-it'
const Gen = require('verify-it').Gen
Provides built-in data generators like `Gen.string`, `Gen.object`, etc.
verify (global)
const verify = init({ it, describe })
verify.it('...', Gen.string, () => {})
The global `verify` object is deprecated since v2.4.0 and will be removed in a future major version. Explicit initialization via `init` is now required to obtain the `verify` object.

Demonstrates initializing `verify-it` with `node:test`, defining tests with randomized inputs using built-in (`Gen.string`, `Gen.object`) and custom generators, and showcasing how generated values can be shared across `verify.describe` blocks.

import test, { describe } from 'node:test' import { init, Gen } from 'verify-it' const verify = init(test) // Initialize verify-it with node:test // A custom generator function const myGenerator = () => `Custom Generated Value: ${Math.random()}` describe('The verify-it library integration', () => { verify.it( 'should inject randomised properties into a test', Gen.string, Gen.object, myGenerator, async (someString, someObject, someCustomValue, t) => { console.log('String:', someString) // Example: 'aRandomString123' console.log('Object:', someObject) // Example: { key: 'value', num: 42 } console.log('Custom:', someCustomValue) // Example: 'Custom Generated Value: 0.123' t.assert.equal(typeof someString, 'string', 'someString should be a string') t.assert.equal(typeof someObject, 'object', 'someObject should be an object') t.assert.equal(someCustomValue.startsWith('Custom Generated Value:'), true, 'someCustomValue should be from the custom generator') } ) verify.describe('when using verify.describe to share values', Gen.number, (sharedNumber) => { verify.it('allows the same generated value to be shared across multiple nested tests', Gen.string, (nestedString, t) => { console.log('Shared Number:', sharedNumber) // Available from the verify.describe scope console.log('Nested String:', nestedString) // Specific to this verify.it test t.assert.equal(typeof sharedNumber, 'number', 'sharedNumber should be a number') t.assert.equal(typeof nestedString, 'string', 'nestedString should be a string') }) verify.it('another test also gets the same shared value', (t) => { console.log('Shared Number again:', sharedNumber) t.assert.equal(typeof sharedNumber, 'number', 'sharedNumber is still available') }) }) })
Debug
Known issues
breakingThe global `verify` object is deprecated since version 2.4.0 and will be removed in a future major version. Relying on it will cause runtime errors in subsequent releases. This change was introduced to improve compatibility with various testing frameworks, especially `node:test`.
fix
Explicitly initialize the library by importing `init` and calling it with your test framework's `it` (or `test`) and `describe` functions. Example: `import { init } from 'verify-it'; import { it, describe } from 'node:test'; const verify = init({ it, describe });`
affects: >=2.4.0
Errors
Common errors & fixes
ReferenceError: verify is not defined
Attempting to use the `verify` object directly without importing `init` and explicitly initializing it, or trying to access the deprecated global `verify` object.
fix
Initialize `verify-it` by importing the `init` function and passing your test framework's `it` (or `test`) and `describe` functions. Example: `import { init } from 'verify-it'; import test from 'node:test'; const verify = init(test);`
Upgrade
Version history
2.4.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
verify-it — npm install verify-it · libregistry