🥽
JSONReporter
JSON formatting, because everything supports JSON
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.
1
// as-pect.config.js
2
const JSONReporter = require("@as-pect/json-reporter").default;
3
4
// export your configuration
5
module.exports = {
6
reporter: new JSONReporter(),
7
};
Copied!
It can also be used from the cli using the --json flag.
1
npm install --save-dev @as-pect/json-reporter
2
npx asp --json
Copied!
The object ouput definition is shaped like this:
1
// Test Results are compiled into an array
2
[
3
// For each test, there is an object with the following shape
4
{
5
// The Test Group
6
group: group.name,
7
// The Test Name
8
name: result.name,
9
// If it ran
10
ran: result.ran,
11
// If it passed
12
pass: result.pass,
13
// The total test runtim
14
runtime: result.runTime,
15
// The error message
16
message: result.message,
17
// Actual value message if an expectation failed
18
actual: result.actual ? result.actual.message : null,
19
// Expected value message if an expectation failed
20
expected: result.expected ? result.expected.message : null,
21
// The average run time (performance)
22
average: result.average,
23
// The median run time (performance)
24
median: result.median,
25
// The maximum run time (performance)
26
max: result.max,
27
// The minimum run time (performance)
28
min: result.min,
29
// The standard deviation of the run times (performance)
30
stdDev: result.stdDev,
31
// The variance of the run times (performance)
32
variance: result.variance,
33
},
34
];
Copied!
Copy link