Skip to content
Novus Examples
json7.3 KB

Mocha — JSON Reporter Output

Mocha's JSON reporter, which lists every test in a tests array and then repeats each one in passes, failures or pending. Summing all four arrays counts the run twice — this file exists so that bug shows up on a 12-test suite instead of in production. Reports the same canonical run as the JUnit dialect files: 12 tests, 9 passed, 1 assertion failure, 1 error and 1 skip.

Preview — first 50 linesjson
{
  "stats": {
    "suites": 3,
    "tests": 12,
    "passes": 9,
    "pending": 1,
    "failures": 2,
    "start": "2026-08-07T09:14:22.031Z",
    "end": "2026-08-07T09:14:29.481Z",
    "duration": 7450
  },
  "tests": [
    {
      "title": "appliesUnitPrice",
      "fullTitle": "cart.PricingTest appliesUnitPrice",
      "file": "test/checkout.spec.js",
      "duration": 643,
      "currentRetry": 0,
      "speed": "fast",
      "err": {}
    },
    {
      "title": "appliesQuantityMultiplier",
      "fullTitle": "cart.PricingTest appliesQuantityMultiplier",
      "file": "test/checkout.spec.js",
      "duration": 659,
      "currentRetry": 0,
      "speed": "fast",
      "err": {}
    },
    {
      "title": "roundsHalfUpAtTwoDecimals",
      "fullTitle": "cart.PricingTest roundsHalfUpAtTwoDecimals",
      "file": "test/checkout.spec.js",
      "duration": 1042,
      "currentRetry": 0,
      "speed": "fast",
      "err": {}
    },
    {
      "title": "rejectsNegativeQuantity",
      "fullTitle": "cart.PricingTest rejectsNegativeQuantity",
      "file": "test/checkout.spec.js",
      "duration": 1048,
      "currentRetry": 0,
      "speed": "fast",
      "err": {}
    },
    {
      "title": "appliesTaxToSubtotal",
253 lines total — download for the full file.

Specifications

Seed
61200
Encoding
UTF-8
Line Endings
LF
Format
mocha --reporter json
Tests
12
Passes
9
Failures
2
Pending
1
Duplicates Tests Into Arrays
true
Arrays
tests, passes, failures, pending

Testing contract

Expected to pass
Scenario
Count tests from a Mocha JSON report without double-counting.
Expected result
The tests array holds all 12; passes, failures and pending are views over the same objects and must not be added to it.

What is a .json file?

JSON (JavaScript Object Notation) is a lightweight, text-based data-interchange format representing objects, arrays, strings, numbers, booleans, and null. It is language-independent, human-readable, and the dominant format for web APIs and configuration. It requires a single well-formed root value.

How to use this file

Use an example JSON file to test parsers and serializers, schema validation, Unicode and number-precision handling, and API request or response processing.

How to use this file for testing

“Mocha — JSON Reporter Output” is a deterministic Novus Examples fixture for JSON parsing, Conversion testing, Error handling. Flat, deeply nested, JSON Lines, and intentionally invalid JSON for testing parsers and error handling.

Documented properties for this file: seed 61200 · UTF-8 · LF. Compare results against paired or grouped companions on this page when present (clean↔damaged, searchable↔scanned, or format twins) so scores stay reproducible across runs.

Download the file once, keep the path stable in CI or local scripts, and treat the spec table as the contract: dimensions, seeds, field lists, and roles are intentional. Corrupt or invalid samples are labelled as such — expect parsers to fail loudly rather than silently accept them.

Test and coverage reports document their totals (suites, cases, passes, failures, skips, covered lines) in the spec table. Point your CI dashboard, coverage gate, or report converter at the file and assert those counts survive; format twins carry identical numbers so a conversion can be scored exactly.

Feed the file to your parser and assert it handles the documented quirks — quoted delimiters, embedded newlines, ragged rows, or invalid syntax; the valid↔invalid distinction is labelled in the title.

Code examples

import json

with open("mocha-json-report.json") as f:
    data = json.load(f)
print(type(data), len(data))

Generated by generation/testing.py. Free for any use, no attribution required — license.