Registry / testing / html-generators

html-generators

JSON →
library1.1.0jsnpmunverified

A library for generating random HTML strings for property-based testing. Version 1.1.0 is stable with no recent releases (last updated 2017). It builds on chance-generators and integrates with unexpected-check and unchecked. Unlike other HTML generators, it produces structurally valid but semantically random HTML documents, including elements, attributes, and content. Supports custom seeds and limits. Suitable for testing HTML parsers, minifiers, sanitizers, and other tools where diverse HTML input is needed.

npm install html-generators
INSTALL
IMPORT
SIG · HTML-GENERATORS
H
html-generators
testingjavascriptv1.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

htmlString
const { htmlString } = require('html-generators')
const htmlString = require('html-generators')
htmlString is a named export, not a default export
htmlFragment
const { htmlFragment } = require('html-generators')
import { htmlFragment } from 'html-generators'
Package uses CommonJS, not ESM. ESM import will fail without bundler
htmlDocument
const { htmlDocument } = require('html-generators')
const htmlDocument = require('html-generators').htmlDocument
Destructuring is preferred but property access also works

Demonstrates generating random HTML strings, fragments, and documents using the three main generators.

const { htmlString, htmlFragment, htmlDocument } = require('html-generators'); const seed = Date.now(); const generator = htmlString({ seed }); console.log(generator.first()); // Output: random HTML string const fragGenerator = htmlFragment({ seed: seed + 1 }); console.log(fragGenerator.first()); const docGenerator = htmlDocument({ seed: seed + 2 }); console.log(docGenerator.first());
Debug
Known issues
deprecatedThe library is in maintenance mode with no updates since 2017.
fix
Consider migrating to a more modern alternative like faker or quick-check.
affects: >=1.0.0
gotchaGenerated HTML may contain invalid attribute values or malformed content.
fix
Do not use for production HTML generation; intended for testing with property-based testing frameworks.
affects: >=1.0.0
breakingCommonJS only – ESM imports will throw 'ERR_REQUIRE_ESM'.
fix
Use require() instead of import, or use a bundler.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'html-generators'
npm package not installed or misspelled
fix
Run 'npm install html-generators' and ensure it is in package.json dependencies.
htmlString is not a function
Used wrong import style – destructing missing or used default import
fix
Use 'const { htmlString } = require('html-generators')'
TypeError: htmlString.first is not a function
htmlString is a factory, not a direct iterator. Must call .first() on the generator instance
fix
Assign result: 'const gen = htmlString(); const result = gen.first();'
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
chance-generatorsrequiredCore dependency providing random value generation (strings, numbers, booleans, etc.)
Agent activity
4 hits · last 30 days
node
4
Resources
html-generators — npm install html-generators · libregistry