{"id":18091,"library":"acquit-require","title":"acquit-require","description":"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.","status":"maintenance","version":"0.1.1","language":"javascript","source_language":"en","source_url":"git://github.com/vkarpov15/acquit-require","tags":["javascript"],"install":[{"cmd":"npm install acquit-require","lang":"bash","label":"npm"},{"cmd":"yarn add acquit-require","lang":"bash","label":"yarn"},{"cmd":"pnpm add acquit-require","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for parsing Mocha tests (required version >=0.4.0)","package":"acquit","optional":false}],"imports":[{"note":"Default import not supported; use named import.","wrong":"import acquitRequire from 'acquit-require'","symbol":"transform","correct":"import { transform } from 'acquit-require'"},{"note":"CJS require is also correct, but ESM named import is preferred.","wrong":"const findTest = require('acquit-require').findTest","symbol":"findTest","correct":"import { findTest } from 'acquit-require'"},{"note":"CommonJS destructuring required; default export does not exist.","wrong":"const transform = require('acquit-require')","symbol":"transform","correct":"const { transform } = require('acquit-require')"}],"quickstart":{"code":"import { transform, findTest } from 'acquit-require';\nimport { readFileSync, writeFileSync } from 'fs';\n\nconst article = readFileSync('./README.md', 'utf8');\nconst testCode = readFileSync('./test/example.test.js', 'utf8');\n\n// Replace [require:...] placeholders with test source code\nconst output = transform(article, testCode);\n\n// Write the new markdown with embedded examples\nwriteFileSync('./README.generated.md', output);\n\n// Example placeholder: [require:my test]\n// The function findTest can be used to locate a single test's body\nconst testBody = findTest('should add numbers', testCode);\nconsole.log('Test source:', testBody);","lang":"typescript","description":"Shows how to load a markdown template and test file, then use transform() to replace placeholders with matching Mocha test code."},"warnings":[{"fix":"Use unique placeholder names, e.g. [require:unique-test-title].","message":"Placeholder 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.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Write tests using `describe('...', function() { it('...', function() { ... }); });`","message":"Only 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.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider forking or using an alternative like 'code-docs-examples'. Test with your specific versions.","message":"Package has not been updated since 2016. It may not work with newer versions of Mocha or Node.js.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run: npm install acquit-require acquit","cause":"Package not installed or missing peer dependency 'acquit'.","error":"Cannot find module 'acquit-require'"},{"fix":"Change to: import { transform } from 'acquit-require'","cause":"Importing default instead of named export.","error":"transform is not a function"},{"fix":"Use named import: import { findTest } from 'acquit-require'","cause":"Importing incorrectly, e.g. as default.","error":"findTest is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}