This (beta) project is a quick and dirty way to wrap around your mocha test runner (available as a global binary or node module) test another of your project, after getting a HTTP request, and feed you with the test results.
- copy
config.json.dist
toconfig.json
and adjust, if you want. - if no adjustments made,
mocha
will try to find your tests in your subproject'stest/mocha.opts
file - go to
subject
(the project being the test subject) directory - remove the
subject/readme.txt
file (it tells you what the directory is for) git clone _YOUR_REPO_URL_ .
to checkout the project inside thesubject
directory.npm install
to make sure all its dependencies are there- go back to
mocha-to-http
directory (cd ..
) ./index.js
will run the test server
The config.json
has all you need to hack around:
default_reporter
— specifies the mocha reporter that will be used if none else specified in the URL parameterscwd
— specifies the working directory for all the commands. Leavingsubject
is recommended.commands.before
— an array of shell commands to be run before the tests. You can putgit pull
ornpm install
orgulp
here, if you want. We recommend using1>&2
at the end of the command to redirect all standard output from the standard output (because that will be returned in the HTTP body) to error output (because that only gets logged on the server console).commands.test
— themocha
command line, if you need any special and custom parameters, ornull
if reading the standardmocha.opts
is fine. We use this, becausemocha.opts
seems incompatible with the coffeescript+testem configuration that we use in the subject project.commands.after
— any cleanup after tests?
A lot. Console output is noisy, the code isn't as pretty as it could for such a simple project. In theory, Windows should be supported, but I'm not sure yet.