{"id":16357854,"url":"https://github.com/carbonfive/mocha-server","last_synced_at":"2025-10-24T02:12:14.589Z","repository":{"id":6539434,"uuid":"7780776","full_name":"carbonfive/mocha-server","owner":"carbonfive","description":null,"archived":false,"fork":false,"pushed_at":"2018-01-16T05:03:47.000Z","size":233,"stargazers_count":8,"open_issues_count":7,"forks_count":4,"subscribers_count":74,"default_branch":"master","last_synced_at":"2024-10-20T20:03:54.700Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/carbonfive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-01-23T18:24:31.000Z","updated_at":"2018-08-19T14:48:41.000Z","dependencies_parsed_at":"2022-09-01T09:20:38.863Z","dependency_job_id":null,"html_url":"https://github.com/carbonfive/mocha-server","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carbonfive%2Fmocha-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carbonfive%2Fmocha-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carbonfive%2Fmocha-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carbonfive%2Fmocha-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carbonfive","download_url":"https://codeload.github.com/carbonfive/mocha-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221842009,"owners_count":16890096,"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":[],"created_at":"2024-10-11T02:04:19.315Z","updated_at":"2025-10-24T02:12:09.568Z","avatar_url":"https://github.com/carbonfive.png","language":"JavaScript","readme":"# mocha-server\n\nRun your front-end [mocha][mocha] tests where they belong; in the browser! Much like [jasmine-gem](https://github.com/pivotal/jasmine), \n\u003ccode\u003emocha-server\u003c/code\u003e serves up your Mocha suite in a web page so you don't have to spend time writing HTML\ntest runners and can focus on the code itself. You can even run them \nthem headlessly with [mocha-phamtomjs][mocha-phantomjs] so they can  be part of your build\nprocess!\n\n## Installation\n\n```sh\nnpm install mocha-server\n```\n\n## Usage\n\nIn its simplest form, you run \u003ccode\u003emocha-server\u003c/code\u003e from the\ncommand-line:\n\n```sh\n$ mocha-server\n```\n\nThis will launch a server that can be accessed at http://localhost:8888\n; open it with a browser to run the mounted tests.\n\nThe following flags can also be used:\n\n```sh\n  Usage: mocha-server [options]\n\n  Options:\n\n    --help               output usage information\n    -V, --version            output the version number\n    -r, --require \u003cname\u003e     require the given module\n    -R, --reporter \u003cname\u003e    specify the reporter to use\n    -u, --ui \u003cname\u003e          specify user-interface (bdd|tdd|exports)\n    -b, --bail               bail after first test failure\n    -h, --headless           run headless with phantomjs\n    -c, --compilers \u003cname\u003e   pass in [ext]:[path to compiler]\n    --agent \u003cuserAgent\u003e      specify the user agent to use\n    --cookie \u003cname\u003e=\u003cvalue\u003e  specify cookie\n    --header \u003cname\u003e=\u003cvalue\u003e  specify custom header\n    --setting \u003ckey\u003e=\u003cvalue\u003e  specify specific phantom settings\n    --view \u003cwidth\u003ex\u003cheight\u003e  specify phantom viewport size\n    --ignore-leaks           ignore global variable leaks\n    --recursive              include sub directories\n```\n\nBy default, tests are pulled in from the \u003ccode\u003etest\u003c/code\u003e directory.\n\n### Load Order\n\nAs dependencies can be very important in running Javascripts code and tests,\n\u003ccode\u003emocha-server\u003c/code\u003e provides two mechanisms for ensuring the load\norder.\n\n#### \u003ccode\u003e--require\u003c/code\u003e\n\nFirst, the \u003ccode\u003e--require\u003c/code\u003e or \u003ccode\u003e-r\u003c/code\u003e flags can be used\nrepeatedly to identify files that should be loaded first. For example:\n\n```sh\n$ mocha-server -r ./test/test-helper.js ./test/my-tests\n```\n\nWill load \u003ccode\u003e./test/test-helper.js\u003c/code\u003e before it loads any of the\ntests found uncer \u003ccode\u003e./test/my-tests\u003c/code\u003e.\n\n#### Sprocket-style \u003ccode\u003erequire\u003c/code\u003e\n\nAlternatively, you can use [sprockets][sprockets] style\n\u003ccode\u003erequire\u003c/code\u003e directives to indicate depdencies. This\nfunctionality is supplied by [snockets][snockets].\n\n#### Adding Additional Javascript Compilers\n\nOut of the box, \u003ccode\u003emocha-server\u003c/code\u003e supports Javascript and\n[coffeescript][coffeescript] files through [snockets][snockets]. You can\npass in additional compilers through the \u003ccode\u003e--compiler\u003c/code flag as\nfollows:\n\n```sh\n$ mocha-server --compiler jade:./test/compilers/jade.js\n```\n\nWill compile all files with the \u003ccode\u003e.jade\u003c/code\u003e extension using the\ncompiler defined in \u003ccode\u003e./test/compilers/jade.js\u003c/code\u003e.\n\nA compiler is made up of a \u003ccode\u003ematch\u003c/code\u003e property that is\nregular-expression that indicates the files type returned and a\n\u003ccode\u003ecompileSync\u003c/code\u003e function that will return the source generated.\n\nLook under the \u003ccode\u003espec/support\u003c/code\u003e for an example compiler.\n\n### \u003ccode\u003emocha-server.opts\u003c/code\u003e\n\nMuch like [mocha][mocha] will attempt to load\n\u003ccode\u003e./test/mocha.opts\u003c/code\u003e, \u003ccode\u003emocha-server\u003c/code\u003e will attempt\nto load \u003ccode\u003e./test/mocha-server.opts\u003c/code\u003e, concatenating the\narguments to those passed on the command line. For example, suppose you\nhave the following:\n\n```\n--require ./test/support\n-h\ntest/assets\n```\n\nIt will ensure the contents of \u003ccode\u003etest/support\u003c/code\u003e is loaded\nfirst, that the tests are run headlessly, and that all the tests in\n\u003ccode\u003etest/assets\u003c/code\u003e are run.\n\n### Running Headlessly\n\n\u003ccode\u003emocha-server\u003c/code\u003e uses [mocha-phantomjs][mocha-phantomjs] to run\nheadlessly. You need to install [PhantomJS v.1.7.0][phantomjs] or\ngreater and then you can enter:\n\n```sh\n$ mocha-server --headless\n```\n\nOr:\n\n```sh\n$ mocha-server -h\n```\n\nThis launches the server, then runs \u003ccode\u003emocha-phantomjs\u003c/code\u003e\nagainst it. Several command-line arguments are passed through to it.\n\n## Examples\n\nThe files under \u003ccode\u003etest\u003c/code\u003e folder provide examples of writing\ntests for the system. You can run them by:\n\n```sh\n$ mocha-server\n```\n\n## Contributing\n\nFork the repo, make a branch, add tests, make your changes, and submit a pull-request!\n\n### Testing\n\nYou can test \u003ccode\u003emocha-server\u003c/code\u003e by cloning this repository and\nrunning:\n\n```sh\n$ cake test\n```\n\nThis will run the tests under the \u003ccode\u003espec\u003c/code\u003e folder.\n\n## Contributors\n\n* [Rudy Jahchan][rudy-jahchan]\n* [Hugo Melo][squanto]\n* [Andrew Peterson][ndp]\n* [Jon Rogers][bunnymatic]\n\n  [bunnymatic]: http://github.com/bunnymatic\n  [ndp]: http://github.com/ndp\n  [squanto]: http://github.com/squanto\n  [rudy-jahchan]: http://github.com/rudyjahchan\n  [mocha-server]: http://github.com/carbonfive/mocha-server\n  [mocha]: http://visionmedia.github.com/mocha/\n  [mocha-phantomjs]: https://github.com/metaskills/mocha-phantomjs\n  [phantomjs]: http://phantomjs.org/\n  [sprockets]: https://github.com/sstephenson/sprockets\n  [snockets]: https://github.com/TrevorBurnham/snockets\n  [coffeescript]: http://coffeescript.org/\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarbonfive%2Fmocha-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarbonfive%2Fmocha-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarbonfive%2Fmocha-server/lists"}