{"id":14967403,"url":"https://github.com/yamadapc/jsdoctest","last_synced_at":"2025-05-02T22:31:15.029Z","repository":{"id":23393028,"uuid":"26754832","full_name":"yamadapc/jsdoctest","owner":"yamadapc","description":"Run jsdoc examples as doctests.","archived":false,"fork":false,"pushed_at":"2021-02-10T21:41:49.000Z","size":2640,"stargazers_count":95,"open_issues_count":8,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-07T07:43:06.038Z","etag":null,"topics":["compiler","doctest","documentation","javascript","jsdoc","mocha","testing"],"latest_commit_sha":null,"homepage":"https://yamadapc.github.io/jsdoctest","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yamadapc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-17T12:04:15.000Z","updated_at":"2025-03-21T11:19:16.000Z","dependencies_parsed_at":"2022-06-28T19:01:45.367Z","dependency_job_id":null,"html_url":"https://github.com/yamadapc/jsdoctest","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamadapc%2Fjsdoctest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamadapc%2Fjsdoctest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamadapc%2Fjsdoctest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamadapc%2Fjsdoctest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yamadapc","download_url":"https://codeload.github.com/yamadapc/jsdoctest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251820578,"owners_count":21649151,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","doctest","documentation","javascript","jsdoc","mocha","testing"],"created_at":"2024-09-24T13:38:00.396Z","updated_at":"2025-05-02T22:31:10.017Z","avatar_url":"https://github.com/yamadapc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"jsdoctest\" src=\"/jsdoctest.png\" /\u003e\n\u003c/p\u003e\n\n[![Build Status](https://travis-ci.org/yamadapc/jsdoctest.svg)](https://travis-ci.org/yamadapc/jsdoctest)\n[![Coverage Status](https://coveralls.io/repos/yamadapc/jsdoctest/badge.png)](https://coveralls.io/r/yamadapc/jsdoctest)\n[![Stories in Ready](https://badge.waffle.io/yamadapc/jsdoctest.svg?label=ready\u0026title=Ready)](http://waffle.io/yamadapc/jsdoctest)\n[![Dependency Status](https://david-dm.org/yamadapc/jsdoctest.svg)](https://david-dm.org/yamadapc/jsdoctest)\n[![devDependency Status](https://david-dm.org/yamadapc/jsdoctest/dev-status.svg)](https://david-dm.org/yamadapc/jsdoctest#info=devDependencies)\n[![npm downloads](http://img.shields.io/npm/dm/jsdoctest.svg)](https://www.npmjs.org/package/jsdoctest)\n[![npm version](http://img.shields.io/npm/v/jsdoctest.svg)](https://www.npmjs.org/package/jsdoctest)\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/yamadapc/jsdoctest?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n\n- - -\n\n**jsdoctest** parses [`jsdoc`](http://usejsdoc.org/) `@example` tags from\nannotated functions and runs them as if they were doctests.\n\nInspired by the [doctest](https://docs.python.org/2/library/doctest.html) python\nlibrary, as well as its [doctestjs](http://doctestjs.org) javascript\nimplementation.\n\n## Demo\n\n![demo](/jsdoctest-demo.gif)\n\n## Set-up\nHere's a two line set-up you can use:\n```bash\n$ npm i -g jsdoctest \u0026\u0026 jsdoctest --init\nAdding `jsdoctest` script to your package.json...\nInstalling `mocha` and `jsdoctest` with npm:\n# ... npm doing some work...\nYou can now run doctests with `npm run jsdoctest` or `npm test`\n```\nThis will add sensible defaults to your `package.json` which you can then edit.\n\n## Test-case Format\nExamples need to be valid javascript, followed by a comment with the string\n` =\u003e ` prefixing the results:\n```javascript\n/**\n * @example\n *   returns10()\n *   // =\u003e 10\n *   returns20()\n *   // =\u003e 20\n */\n```\n\nIt doesn't matter if the comment is on the same line or the next one, so the\nfollowing is also valid:\n```javascript\n/**\n * @example\n *   returns10() // =\u003e 10\n *   returns20()\n *   // =\u003e 20\n */\n```\n\n**Async test cases** are supported prefixing the expected results with the\n` async =\u003e ` string and pretending to have the `cb` callback function.\n```javascript\n/**\n * @example\n *   takesCallbackAndYields10('here', cb)\n *   // async =\u003e 10\n *   takesCallbackAndYields20('here', cb)\n *   // async =\u003e 30\n */\n```\n\n**Promises** are also supported, just add the same `// async =\u003e` prefix and be\nsure not to use a variable named `cb` on your text expression.\n```javascript\n/**\n * @example\n *   returnsPromiseThatYields10('here')\n *   // async =\u003e 10\n */\n```\n\n## Examples\nThe [examples](/examples) directory has a couple of examples, which may be\nuseful. Better documentation will be added if the project raises in complexity.\n\n## Usage\nThe recommended way of using jsdoctest is to use\n[`mocha`](https://github.com/mochajs/mocha). That is made possible with:\n```bash\nnpm i mocha jsdoctest\nmocha --require jsdoctest \u003cmodule-name\u003e\n```\n\nThere's also a rudimentary command-line interface, which can be ran with:\n```bash\nnpm i jsdoctest\njsdoctest \u003cmodule-name\u003e\n```\n\n## Disabling\nTo disable running jsdoctests, while still requiring it with `mocha` (I don't\nknow why, but you may) you can set the `JSDOCTEST_DISABLE` environment variable\nto anything (`JSDOCTEST_DISABLE=true mocha --require...`).\n\n## License\nThis code is licensed under the MIT license for Pedro Tacla Yamada. For more\ninformation, please refer to the [LICENSE](/LICENSE) file.\n\n## Donations\nWould you like to buy me a beer? Send bitcoin to 3JjxJydvoJjTrhLL86LGMc8cNB16pTAF3y\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyamadapc%2Fjsdoctest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyamadapc%2Fjsdoctest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyamadapc%2Fjsdoctest/lists"}