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-generatorVerified import paths — ran on the pinned version, not inferred.
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.
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.
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`.
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.
Use the CommonJS `require` syntax: `const generate = require('json-schema-test-data-generator');`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`.
No dependency data recorded yet.