Clone this wiki locally
When all tests have been completed and the results object has been returned, you can post those results to a server using a
YUITest.Reporter object. A
YUITest.Reporter object creates a form that is POSTed to a specific URL with the following fields:
results- the serialized results object.
useragent- the user-agent string of the browser.
timestamp- the date and time that the report was sent.
You can create a new
YUITest.Reporter object by passing in the URL to report to. The results object can
then be passed into the
report() method to submit the results:
var reporter = new YUITest.Reporter("http://www.yourserver.com/path/to/target"); reporter.report(results);
The form submission happens behind-the-scenes and will not cause your page to navigate away. This operation is one direction; the reporter does not get any content back from the server. There are four output formats for results objects:
* `YUITest.TestFormat.XML` (default) * `YUITest.TestFormat.JSON` * `YUITest.TestFormat.JUnitXML` * `YUITest.TestFormat.TAP`
The format in which to submit the results can be specified in the
YUITest.Reporter constructor by passing in the appropriate
YUITest.TestFormat value (when no argument is specified,
YUITest.TestFormat.XML is used:
var reporter = new YUITest.Reporter("http://www.yourserver.com/path/to/target", YUITest.TestFormat.JSON);
You can optionally specify additional fields to be sent with the results report by using the
addField() method. This method accepts two arguments: a name and a value. Any field added using
addField() is POSTed along with the default fields back to the server:
reporter.addField("color", "blue"); reporter.addField("message", "Hello world!");
Note that if you specify a field name that is the same as a default field, the custom field is ignored in favor of the default field.