JS runtime reporter for Mocha.
Runtime reporter for Mocha in Jasmine JS-Reporter format.
This is a Mocha reporter, designed to simplify the extraction of test results from the Page. It's tailored with Test Reporting Automation in mind.
Ideal scenario of use are:
- Use Selenium Web Driver to extract the result out of the page
- Use PhantomJS to do... well, the same as above
- Every time you wish Jasmine produced a JSON to report about the tests
The Reporter awaits for all the Test to finish, than produces a report that can be retrieved with
var JSONReport = mocha.getJSReport ();
and looks like the following:
{
"suites": [
{
"description": "Simple test that checks the obvious regarding Truthy-ness and Falsy-ness",
"durationSec": 0.005,
"specs": [
{
"description": "should report that a number is truthy, if different than '0', falsy otherwise",
"durationSec": 0.004,
"passed": true,
"skipped": false,
},
// ... more specs here...
],
"suites": [],
"passed": true
}
],
"durationSec": 0.005,
"passed": true
}
After that, you can just extract it from the page.
- Download the code:
git clone http://github.com/darvin/mocha-js-reporter.git
- Include the reporter in your page running Jasmine tests with something like:
<script src="path/to/mocha-js-reporter.js" type="text/javascript"></script>
- Open your WebInspector, Firebug or whatever you use
- On the console, type:
mocha.getJSReport ()
- Check that you get an Object back (should look like the above one)
- You are done!
Now you can setup your Test Infrastructure to extract test results from the test page, in the same way I just showed you.