Registry / testing / acquit-require

acquit-require

JSON →
library0.1.1jsnpmunverified

Utility to extract example code from Mocha test files and embed it into markdown, HTML, or other documentation formats via placeholder directives like `[require:testName]`. Version 0.1.1 is the latest stable release, last updated in 2016 with no active development. Requires peer dependency `acquit >= 0.4.0`. Differentiates from generic doc generators by providing a simple, test‑driven approach to keep documentation in sync with actual tests.

npm install acquit-require
INSTALL
IMPORT
SIG · ACQUIT-REQUIRE
A
acquit-require
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.

transform
import { transform } from 'acquit-require'
import acquitRequire from 'acquit-require'
Default import not supported; use named import.
findTest
import { findTest } from 'acquit-require'
const findTest = require('acquit-require').findTest
CJS require is also correct, but ESM named import is preferred.
transform
const { transform } = require('acquit-require')
const transform = require('acquit-require')
CommonJS destructuring required; default export does not exist.

Shows how to load a markdown template and test file, then use transform() to replace placeholders with matching Mocha test code.

import { transform, findTest } from 'acquit-require'; import { readFileSync, writeFileSync } from 'fs'; const article = readFileSync('./README.md', 'utf8'); const testCode = readFileSync('./test/example.test.js', 'utf8'); // Replace [require:...] placeholders with test source code const output = transform(article, testCode); // Write the new markdown with embedded examples writeFileSync('./README.generated.md', output); // Example placeholder: [require:my test] // The function findTest can be used to locate a single test's body const testBody = findTest('should add numbers', testCode); console.log('Test source:', testBody);
Debug
Known issues
gotchaPlaceholder matching is case‑insensitive and only matches the first test whose full name contains the placeholder text as a substring. This can lead to unexpected replacements if test names overlap.
fix
Use unique placeholder names, e.g. [require:unique-test-title].
affects: >=0.0.0
gotchaOnly tests written with the standard Mocha `describe/it` pattern are supported. Tests using `context`, `specify`, or arrow functions without a `function()` keyword may not be matched.
fix
Write tests using `describe('...', function() { it('...', function() { ... }); });`
affects: >=0.0.0
deprecatedPackage has not been updated since 2016. It may not work with newer versions of Mocha or Node.js.
fix
Consider forking or using an alternative like 'code-docs-examples'. Test with your specific versions.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'acquit-require'
Package not installed or missing peer dependency 'acquit'.
fix
Run: npm install acquit-require acquit
transform is not a function
Importing default instead of named export.
fix
Change to: import { transform } from 'acquit-require'
findTest is not a function
Importing incorrectly, e.g. as default.
fix
Use named import: import { findTest } from 'acquit-require'
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
acquitrequiredPeer dependency for parsing Mocha tests (required version >=0.4.0)
Agent activity
50 hits · last 30 days
node
38
OpenAI (training)
1
Resources