# Project Integration
After simply processing the data generated by Mocha, you can call the macaca-reporter/lib/render method to generate the reporter.
# Get Data
After each test case is completed in Mocha, the data is processed and the data is finally output locally.
code:
const handleTestEnd = (isEnd) => {
const obj = getSuiteData(isEnd);
obj.stats.duration = obj.suites._totalTime || 0;
this.output = obj;
};
this.done = (failures, exit) => done(this.output, this.config, failures, exit);
runner.on('start', () => {
this._originSuiteData = runner.suite;
});
runner.on('test end', test => {
test.uuid = uuid();
handleTestEnd();
});
runner.once('end', () => {
handleTestEnd(true);
self.epilogue.bind(self);
});
code: uitest (opens new window): start (opens new window) - end (opens new window)
# Reporter
After the data is generated, the reporter page is rendered by the render method:
const render = require('macaca-reporter/lib/render');
const data = require('./reports/json-final');
render(data);
# Jest Project
macaca-reporter-jest (opens new window)