Skip to content
Skillpedia
Testing9.1k Β· #12305

reporting

What it does

This skill explains how to control what Ginkgo test results look like and how to save them as machine-readable reports. It is for developers who want clear test output or reports for other tools.

When to use it

  • βœ“When you want more or less detail in the test results shown on screen.
  • βœ“When you need a JSON or JUnit report file from your Ginkgo tests.
  • βœ“When you want to check code coverage or performance of Go tests.

Skill link

https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/reporting/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/reporting/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œCan you make my Go tests save a JUnit report so our CI system can read it?”

5 new skills a week. 1 minute to read.

How it works

It shows the command options that print detailed output, write report files, and measure coverage or speed.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Reporting and profiling

How to produce reports and feed data into them. To read a failing report as an agent (the jq failure-diagnosis workflow), see ginkgo:debugging-failures. Docs: https://onsi.github.io/ginkgo/#generating-machine-readable-reports and https://onsi.github.io/ginkgo/#attaching-data-to-reports.

Console output

Flag Effect
--succinct Minimal (default when running multiple suites).
(none) Normal β€” detail only for failed specs (default, single suite).
-v Full timeline for every spec; streams live in series.
-vv -v plus node > Enter/< Exit events and every failure (not just the primary).
--trace Full stack trace on every failure, not just panics.
--no-color / GINKGO_NO_COLOR=TRUE Disable color.
--github-output Format console output for GitHub Actions.

In parallel (-p), -v/-vv timelines can't stream β€” the streams would interleave, so Ginkgo emits each spec's full timeline after that spec completes. β†’ CI flags in ginkgo:ci.

Machine-readable reports

ginkgo -r --json-report=report.json --output-dir=./.reports
  • --json-report is native and richest β€” an array of types.Report, each with SpecReports[] of types.SpecReport (godoc); build tooling against the types package.
  • --junit-report=x.xml, --teamcity-report=x, --gojson-report=x.go.json exist for external CI but lose Ginkgo metadata β€” use them to feed a system, not to diagnose. (JUnit maps a Label("owner:XYZ") to the Owner attribute.)
  • --output-dir=DIR collects all files in one place; under -r all suites merge into one report file. --keep-separate-reports writes one PACKAGE_report.json per package instead.
  • Every machine-readable report embeds the full -vv timeline regardless of console verbosity. Run the suite quiet and mine the file β€” you don't need -vv on the console to get rich detail in the report.

Programmatic reporting nodes

CurrentSpecReport() works in any run-phase closure β€” use it for in-spec conditional diagnostics:

AfterEach(func() {
  if CurrentSpecReport().Failed() {
    GinkgoWriter.Println(libraryClient.DebugLogs())   // expensive diagnostics, only on failure
  }
})

For custom report files, don't roll your own in AfterEach β€” use reporting nodes:

  • ReportAfterEach(func(r SpecReport){...}) / ReportBeforeEach β€” run for every spec including skipped/pending (unlike AfterEach), after all AfterEaches. A failure here fails the spec. In parallel they run on each process concurrently β€” never write a shared file from them (you'll get interleaved garbage).
  • ReportBeforeSuite / ReportAfterSuite("name", func(r Report){...}) β€” top-level, and run only on process #1. ReportAfterSuite receives the Report aggregated across all parallel processes β€” this is the safe place for custom suite-level report files:
ReportAfterSuite("custom report", func(report Report) {
  f, _ := os.Create("report.custom")
  for _, sr := range report.SpecReports {
    fmt.Fprintf(f, "%s | %s\n", sr.FullText(), sr.State)
  }
  f.Close()
})

Reporting nodes can be made interruptible by also accepting SpecContext β†’ ginkgo:timeouts-and-async.

Attaching data to a spec: AddReportEntry

It("is reported", func() {
  AddReportEntry("Publish stats", stats, ReportEntryVisibilityFailureOrVerbose)
})

AddReportEntry(name, value, ...args) attaches arbitrary data to the current spec; it lands in SpecReport.ReportEntries, in all machine-readable reports, and (per visibility) on the console. Visibility enum:

  • ReportEntryVisibilityAlways (default) β€” always printed.
  • ReportEntryVisibilityFailureOrVerbose β€” only on failure or -v (like GinkgoWriter).
  • ReportEntryVisibilityNever β€” never on console, but still in the JSON report.

For failure-only diagnostics, call AddReportEntry from a DeferOnFailure callback (β†’ ginkgo:writing-specs).

value is JSON-round-tripped into the report (retrieve via entry.GetRawValue() / json.Unmarshal(entry.Value.AsJSON, ...)). A fmt.Stringer/types.ColorableStringer controls console rendering; pass a pointer to capture later mutations. AddReportEntry decorators (Offset, CodeLocation, ReportEntryVisibility) β†’ ginkgo:decorators.

Recap (owned by ginkgo:writing-specs): GinkgoWriter buffers log output a

FAQ

What is a JUnit report?

It is a standard file format that many build and test systems can read to show test results.

Can I see every test as it runs?

Yes, the verbose options show a timeline for every test, though parallel runs show each timeline after that test finishes.

Does this skill change my tests?

It mainly covers command options and reporting code, so your tests stay the same unless you add reporting steps.

Details

Original description by the author

Generate, consume, and enrich Ginkgo reports β€” console verbosity (-v/-vv/--trace/--no-color/--succinct), machine-readable reports (--json-report/--junit-report with --output-dir/--keep-separate-reports), programmatic reporting nodes (ReportAfterEach, ReportAfterSuite, CurrentSpecReport), AddReportEntry with ReportEntryVisibility, and profiling (--cover/--race/--cpuprofile/--memprofile). Use when you need a report file, custom suite-level reporting, attaching data to a spec, controlling console output, or profiling a suite.

repo: onsi/ginkgo

Popularity

GitHub stars
9.1k
Ranking position
#12305
License
MIT
Updated
10/9/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills