The JSONReporter can be used to create json files that contain the test output. The file output location is {testname}.spec.json. It can be used directly from the configuration file.
It must be installed manually via the CLI.
// as-pect.config.jsconstJSONReporter=require("@as-pect/json-reporter").default;// export your configurationmodule.exports= { reporter:newJSONReporter(),};
It can also be used from the cli using the --json flag.
npm install --save-dev @as-pect/json-reporter
npx asp --json
The object ouput definition is shaped like this:
// Test Results are compiled into an array[// For each test, there is an object with the following shape {// The Test Group group:group.name,// The Test Name name:result.name,// If it ran ran:result.ran,// If it passed pass:result.pass,// The total test runtim runtime:result.runTime,// The error message message:result.message,// Actual value message if an expectation failed actual:result.actual ?result.actual.message :null,// Expected value message if an expectation failed expected:result.expected ?result.expected.message :null,// The average run time (performance) average:result.average,// The median run time (performance) median:result.median,// The maximum run time (performance) max:result.max,// The minimum run time (performance) min:result.min,// The standard deviation of the run times (performance) stdDev:result.stdDev,// The variance of the run times (performance) variance:result.variance, },];