{"id":13473266,"url":"https://github.com/sindresorhus/gulp-mocha","last_synced_at":"2025-05-15T11:06:45.875Z","repository":{"id":12525030,"uuid":"15194907","full_name":"sindresorhus/gulp-mocha","owner":"sindresorhus","description":"Run Mocha tests","archived":false,"fork":false,"pushed_at":"2024-04-19T21:08:55.000Z","size":104,"stargazers_count":376,"open_issues_count":11,"forks_count":86,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-23T02:27:14.074Z","etag":null,"topics":["gulp-plugin","javascript","mocha","nodejs","test-runner"],"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/sindresorhus.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":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2013-12-14T23:50:56.000Z","updated_at":"2025-04-13T19:16:35.000Z","dependencies_parsed_at":"2024-04-13T12:20:36.809Z","dependency_job_id":"ddbac66f-c95f-4f09-969c-8906d11f27e1","html_url":"https://github.com/sindresorhus/gulp-mocha","commit_stats":{"total_commits":141,"total_committers":44,"mean_commits":"3.2045454545454546","dds":"0.35460992907801414","last_synced_commit":"61a01800e50cecf984035d4043a205840f2c2646"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fgulp-mocha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fgulp-mocha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fgulp-mocha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fgulp-mocha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/gulp-mocha/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251951851,"owners_count":21670297,"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":["gulp-plugin","javascript","mocha","nodejs","test-runner"],"created_at":"2024-07-31T16:01:02.226Z","updated_at":"2025-05-15T11:06:45.856Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["JavaScript","Plugins","插件"],"sub_categories":["Testing","测试"],"readme":"# gulp-mocha\n\n\u003e Run [Mocha](https://github.com/mochajs/mocha) tests\n\n*Keep in mind that this is just a thin wrapper around Mocha and your issue is most likely with Mocha.*\n\n## Install\n\n```sh\nnpm install --save-dev gulp-mocha\n```\n\n## Usage\n\n```js\nimport gulp from 'gulp';\nimport mocha from 'gulp-mocha';\n\nexport default () =\u003e (\n\tgulp.src('test.js', {read: false})\n\t\t// `gulp-mocha` needs file paths so you cannot have any plugins before it.\n\t\t.pipe(mocha({reporter: 'nyan'}))\n);\n```\n\n## API\n\n### mocha(options?)\n\n#### options\n\nType: `object`\n\nOptions are passed directly to the `mocha` binary, so you can use any its [command-line options](http://mochajs.org/#usage) in a camelCased form. Arrays and key/value objects are correctly converted to the comma separated list format Mocha expects. Listed below are some of the more commonly used options:\n\n##### ui\n\nType: `string`\\\nDefault: `'bdd'`\\\nValues: `'bdd' | 'tdd' | 'qunit' | 'exports'`\n\nThe interface to use.\n\n##### reporter\n\nType: `string`\\\nDefault: `spec`\\\nValues: [Reporters](https://github.com/mochajs/mocha/tree/master/lib/reporters)\n\nThe reporter that will be used.\n\nThis option can also be used to utilize third-party reporters. For example, if you `npm install mocha-lcov-reporter` you can then do use `mocha-lcov-reporter` as value.\n\n##### reporterOptions\n\nType: `object`\\\nExample: `{reportFilename: 'index.html'}`\n\nReporter specific options.\n\n##### globals\n\nType: `string[]`\n\nList of accepted global variable names, example `['YUI']`. Accepts wildcards to match multiple global variables, e.g. `['gulp*']` or even `['*']`. See [Mocha globals option](http://mochajs.org/#globals-option).\n\n##### timeout\n\nType: `number`\\\nDefault: `2000`\n\nTest-case timeout in milliseconds.\n\n##### bail\n\nType: `boolean`\\\nDefault: `false`\n\nBail on the first test failure.\n\n##### checkLeaks\n\nType: `boolean`\\\nDefault: `false`\n\nCheck for global variable leaks.\n\n##### grep\n\nType: `string`\n\nOnly run tests matching the given pattern which is internally compiled to a RegExp.\n\n##### require\n\nType: `string[]`\n\nRequire custom modules before tests are run.\n\n##### compilers\n\nType: `string`\\\nExample: `js:babel-core/register`\n\nSpecify a compiler.\n\n## FAQ\n\n### Test suite not exiting\n\nIf your test suite is not exiting it might be because you still have a lingering callback, most often caused by an open database connection. You should close this connection or do the following:\n\n```js\nexport default () =\u003e (\n\tgulp.src('test.js')\n\t\t.pipe(mocha())\n\t\t.once('error', err =\u003e {\n\t\t\tconsole.error(err);\n\t\t\tprocess.exit(1);\n\t\t})\n\t\t.once('end', () =\u003e {\n\t\t\tprocess.exit();\n\t\t})\n);\n```\n\nOr you might just need to pass the `exit` option:\n\n```js\nexport const test = () =\u003e (\n\tgulp.src(['test/**/*.js'], {read: false})\n\t\t.pipe(mocha({reporter: 'list', exit: true}))\n\t\t.on('error', console.error)\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fgulp-mocha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fgulp-mocha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fgulp-mocha/lists"}