โšก
as-pect
  • โšกas-pect
  • ๐Ÿš€Getting Started
  • ๐Ÿ”งCLI Configuration
  • ๐Ÿ—๏ธAssemblyScript API
    • ๐Ÿ›๏ธTest Structure
    • ๐Ÿคทโ€โ™€๏ธ Expectations
      • ๐ŸŽญtoBe
      • ๐ŸคจtoStrictEqual
      • ๐ŸงฑtoBlockEqual
      • ๐Ÿ‘ฉโ€๐Ÿซ toBeTruthy and toBeFalsy
      • ๐Ÿ”ขtoBeNaN
      • ๐ŸšซtoBeNull
      • ๐ŸŒŒtoBeFinite
      • โšพtoThrow
      • โž•toBe(Greater|Less)Than
      • ๐Ÿ•ต๏ธโ€โ™€๏ธ toBeCloseTo
      • ๐Ÿ“toHaveLength
      • ๐ŸŽtoContain
      • ๐Ÿ“ฆtoContainEqual
      • โœ๏ธCustom Assertions
    • ๐ŸŽŸ๏ธTypes and Tooling
    • ๐Ÿช“Logging
    • ๐Ÿ‘ฉโ€๐Ÿ”ง RTrace and Memory Leaks
    • ๐Ÿ‘‰๐Ÿ‘ˆ Reflection
  • ๐ŸงถCore API
    • ๐ŸงชTestContext
    • ๐Ÿ‘ขBootstrap Tests Manually
    • ๐ŸŽ›๏ธTestGroup
    • โœ”๏ธTestResult
    • โœ๏ธReporters
      • ๐ŸฉณSummaryReporter
      • ๐Ÿ’ฌVerboseReporter
      • ๐ŸฅฝJSONReporter
      • ๐Ÿ—ƒ๏ธCSVReporter
Powered by GitBook
On this page

Was this helpful?

  1. Core API
  2. Reporters

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.

// as-pect.config.js
const JSONReporter = require("@as-pect/json-reporter").default;

// export your configuration
module.exports = {
  reporter: new JSONReporter(),
};

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,
  },
];
PreviousVerboseReporterNextCSVReporter

Last updated 5 years ago

Was this helpful?

๐Ÿงถ
โœ๏ธ
๐Ÿฅฝ