REST-EZ has several built-in reporters, json
, specs
, html
etc.
When you need a HTML report, you can invoke rest-ez with the --reporter
option
Basic example:
1link$./node_modules/.bin/rest-ez --reporter html
Advanced example:
1link$./node_modules/.bin/rest-ez --reporter html,json --reporter-options jsonReportDir=reports,jsonReportName=json-report,htmlReportDir=reports,htmlReportName=html-report,logRequests
REST-EZ can generate reports in multiple formats.
When you need a HTML report and a JSON report too, you could do something like this
1link$./node_modules/.bin/rest-ez --reporter html,json
This way you can generate reports in multiple formats for the same run.
REST-EZ accepts an additonal command line option --reporter-options
that you can use to customize how and where reports are generated and saved.
You must pass a comma separated list of key and value pairs to this option as k=v,k2=v2,...
test-reports
[cwd]
Provide an existing directory path that is relative to REST-EZ node process's cwd. JSON report will be saved to this directory.
1link$./node_modules/.bin/rest-ez --reporter json --reporter-options jsonReportDir=test-reports
# Outputs to: test-reports/report.json
test-report.json
report.json
Provide a name for the JSON report file. JSON report will be saved with this name.
1link$./node_modules/.bin/rest-ez --reporter json --reporter-options jsonReportName=test-report.json
# Outputs to: test-report.json
test-reports/
[cwd]
Provide an existing directory path that is relative to REST-EZ node process's cwd. HTML report will be saved to this directory.
1link$./node_modules/.bin/rest-ez --reporter json --reporter-options htmlReportDir=reports,htmlReportName=test-report.json
# Outputs to: reports/test-report.json
test-report.html
report.html
Provide a name for the HTML report file. HTML report will be saved with this name.
1link$./node_modules/.bin/rest-ez --reporter json --reporter-options htmlReportDir=html-reports,htmlReportName=latest-report.json
# Outputs to: html-reports/latest-report.json
true
false
(if not provided)Tells REST-EZ to log HTTP request & response details in reports for failed tests. Omit this if you don't want to log details.
Log all failed requests in an HTML report:
1link$./node_modules/.bin/rest-ez --reporter html --reporter-options logRequests
Log all failed requests in a JSON report:
1link$./node_modules/.bin/rest-ez --reporter json --reporter-options logRequests
You can write your own custom reporter.
See also: REST-EZ Built-In JSON Reporter
Reporters are JS constructors. When instantiated, a reporter receives the test launcher object along with program options.
Using a node module by name:
1link$./node_modules/.bin/rest-ez --reporter html,custom-reporter-module-name
Using a path to a file:
1link$./node_modules/.bin/rest-ez --reporter html,/absolute/path/to/js/file
REST-EZ emits events on launcher object and suite object, So a custom reporter should listen to these events and implement reporting.
1linkclass Reporter {
2link
3link constructor(launcher, opts = {}) {
4link
5link }
6link
7link addSuite(suite) {
8link
9link }
10link
11link getSuite(location) {
12link
13link }
14link}