{"id":14967376,"url":"https://github.com/blakeembrey/co-mocha","last_synced_at":"2025-04-05T02:08:06.897Z","repository":{"id":13789981,"uuid":"16485370","full_name":"blakeembrey/co-mocha","owner":"blakeembrey","description":"Enable support for generators in Mocha tests","archived":false,"fork":false,"pushed_at":"2018-02-27T05:24:48.000Z","size":52,"stargazers_count":215,"open_issues_count":1,"forks_count":20,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-01T05:36:10.468Z","etag":null,"topics":["generator","javascript","mocha"],"latest_commit_sha":null,"homepage":null,"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/blakeembrey.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-02-03T16:39:44.000Z","updated_at":"2024-05-16T17:24:09.000Z","dependencies_parsed_at":"2022-09-11T06:51:38.341Z","dependency_job_id":null,"html_url":"https://github.com/blakeembrey/co-mocha","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakeembrey%2Fco-mocha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakeembrey%2Fco-mocha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakeembrey%2Fco-mocha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakeembrey%2Fco-mocha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blakeembrey","download_url":"https://codeload.github.com/blakeembrey/co-mocha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256110,"owners_count":20909240,"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":["generator","javascript","mocha"],"created_at":"2024-09-24T13:37:57.592Z","updated_at":"2025-04-05T02:08:06.878Z","avatar_url":"https://github.com/blakeembrey.png","language":"JavaScript","readme":"# Co Mocha\n\n[![NPM version][npm-image]][npm-url]\n[![NPM downloads][downloads-image]][downloads-url]\n[![Build status][travis-image]][travis-url]\n[![Test coverage][coveralls-image]][coveralls-url]\n[![Greenkeeper badge](https://badges.greenkeeper.io/blakeembrey/co-mocha.svg)](https://greenkeeper.io/)\n\nEnable support for generators in Mocha tests using [co](https://github.com/visionmedia/co).\n\nUse the `--harmony-generators` flag when running node 0.11.x to access generator functions, or transpile your tests using [traceur](https://github.com/google/traceur-compiler) or [regenerator](https://github.com/facebook/regenerator).\n\n## Installation\n\n```\nnpm install co-mocha --save-dev\n```\n\n## Usage\n\nJust require the module in your tests and start writing generators in your tests.\n\n```js\nit('should do something', function * () {\n  yield users.load(123)\n})\n```\n\n### Node\n\nInstall the module using `npm install co-mocha --save-dev`. Now just require the module to automatically monkey patch any available `mocha` instances. With `mocha`, you have multiple ways of requiring the module - add `--require co-mocha` to your `mocha.opts` or add `require('co-mocha')` inside your main test file.\n\nIf you need to monkey patch a different mocha instance you can use the library directly:\n\n```js\nvar mocha = require('mocha')\nvar coMocha = require('co-mocha')\n\ncoMocha(mocha)\n```\n\n### `\u003cscript\u003e` Tag\n\n```html\n\u003cscript src=\"co-mocha.js\"\u003e\u003c/script\u003e\n```\n\nIncluding the browserified script will automatically patch `window.Mocha`. Just make sure you include it after `mocha.js`. If that is not possible the library exposes `window.coMocha`, which can be used (`window.coMocha(window.Mocha)`).\n\n### AMD\n\nSame details as the script, but using AMD requires instead.\n\n## How It Works\n\nThe module monkey patches the `Runnable.prototype.run` method of `mocha` to enable generators. In contrast to other npm packages, `co-mocha` extends `mocha` at runtime - allowing you to use any compatible mocha version.\n\n## License\n\nMIT\n\n[npm-image]: https://img.shields.io/npm/v/co-mocha.svg?style=flat\n[npm-url]: https://npmjs.org/package/co-mocha\n[downloads-image]: https://img.shields.io/npm/dm/co-mocha.svg?style=flat\n[downloads-url]: https://npmjs.org/package/co-mocha\n[travis-image]: https://img.shields.io/travis/blakeembrey/co-mocha.svg?style=flat\n[travis-url]: https://travis-ci.org/blakeembrey/co-mocha\n[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/co-mocha.svg?style=flat\n[coveralls-url]: https://coveralls.io/r/blakeembrey/co-mocha?branch=master\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakeembrey%2Fco-mocha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblakeembrey%2Fco-mocha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakeembrey%2Fco-mocha/lists"}