Registry / testing / json-schema-test-data-generator

json-schema-test-data-generator

JSON →
library0.1.1jsnpmunverified

The `json-schema-test-data-generator` utility is designed to create sample test data objects based on a provided JSON schema. It generates an array of test scenarios, each indicating whether the generated data is `valid` against the schema, the `data` itself, a descriptive `message`, and an optional `property` key. As of version 0.1.1, the package is considered abandoned, with its last commit occurring 8 years ago. It focuses on covering various combinations for testing against a schema, including required and optional properties, and basic type mismatches. Its primary differentiator is generating both valid and intentionally invalid data scenarios with descriptive messages, helping users quickly create a test suite without manual data construction. Due to its abandoned status, users should be aware that it will not receive bug fixes, security updates, or new features, and might not support newer JSON Schema drafts or complex constructs.

npm install json-schema-test-data-generator
INSTALL
IMPORT
SIG · JSON-SCHEMA-TEST-D
J
json-schema-test-data-generator
testingjavascriptv0.1.1
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.

generate
const generate = require('json-schema-test-data-generator');
import generate from 'json-schema-test-data-generator';
This package is CommonJS-only. Direct ESM imports are not supported and will require transpilation or a CommonJS wrapper.

This quickstart demonstrates how to import the generator and use it with a basic JSON schema to produce an array of test data objects, including both valid and invalid scenarios.

const generate = require('json-schema-test-data-generator'); const schema = { "type": "object", "properties": { "name": { "type": "string", "minLength": 5 }, "active": { "type": "boolean" }, "email": { "type": "string", "format": "email" }, "accountNumber": { "type": "number" } }, "required": ["name", "email"] } console.dir(generate(schema));
json-schema-test-data-generator --version
Debug
Known issues
breakingThe project is abandoned, with the last code changes dating back 8 years. This means there will be no further updates, bug fixes, or security patches, which could lead to unaddressed vulnerabilities or compatibility issues with newer Node.js versions or JSON Schema drafts.
fix
Consider migrating to actively maintained alternatives like `json-schema-faker` or `json-schema-generator` for better support and features, especially if working with modern JSON Schema drafts or requiring `$ref` resolution.
affects: 0.1.1
gotchaThe generator does not support `$ref` keywords in JSON schemas. Schemas must be 'fully expanded' before being passed to the `generate` function, meaning all references must be resolved beforehand.
fix
Manually dereference your JSON schemas using a separate tool or library (e.g., `json-schema-deref`) before passing them to `json-schema-test-data-generator`. Alternatively, use a generator that natively supports `$ref`.
affects: 0.1.1
gotchaThe utility generates 'various (but not all) combinations' of test data. This means complex JSON Schema constructs (e.g., `oneOf`, `anyOf`, `not`, advanced array/object constraints, specific string patterns) might not be fully covered, potentially leading to incomplete test suites.
fix
Manually review the generated test data to ensure all critical schema paths and edge cases are covered. For comprehensive testing, consider supplementing with hand-crafted test cases or using more robust, actively developed schema fakers.
affects: 0.1.1
Errors
Common errors & fixes
TypeError: generate is not a function
Attempting to use `import generate from 'json-schema-test-data-generator';` in a modern ESM environment without proper CommonJS interoperability.
fix
Use the CommonJS `require` syntax: `const generate = require('json-schema-test-data-generator');`
Generated data does not match schema expectations for complex types (e.g., allOf, anyOf)
The generator has limited support for complex JSON Schema keywords and might not correctly interpret or generate data for all possible combinations.
fix
This package is noted to cover 'various (but not all)' combinations. For schemas using advanced keywords like `allOf`, `anyOf`, `oneOf`, or `not`, manual inspection of generated tests is required. If the coverage is insufficient, consider a different, more actively maintained library that explicitly lists support for these keywords, such as `json-schema-faker`.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
json-schema-test-data-generator — npm install json-schema-test-data-generator · libregistry