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

overview

What it does

This skill gives a clear picture of how the Ginkgo testing tool for Go works. It is for developers starting a Ginkgo test project or planning a testing task.

When to use it

  • βœ“When you start working with Ginkgo tests in a Go project for the first time.
  • βœ“When you need to decide how to approach a testing task in a Ginkgo project.
  • βœ“When your Ginkgo tests behave in a way you did not expect.

Skill link

https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/overview/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/overview/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

β€œI am new to Ginkgo for Go, can you explain how its tests are organized before we start?”

5 new skills a week. 1 minute to read.

How it works

It explains that Ginkgo first builds a list of all the tests and then runs them, and it points to other guides for specific topics.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Ginkgo: the mental model

Ginkgo is an expressive BDD-style testing framework for Go, paired with the Gomega matcher library. You build suites out of nested container nodes (Describe/Context/When) and subject nodes (It), with setup nodes (BeforeEach/AfterEach/…) supplying state. You drive it with the ginkgo CLI. Strongly prefer ginkgo over go test.

Read the canonical narrative docs at https://onsi.github.io/ginkgo/ β€” they are the source of truth. This skill is the orientation; the other skills go deep.

The one idea: tree construction, then running

Ginkgo runs your suite in two distinct phases. Internalizing this explains nearly every Ginkgo gotcha:

  1. Tree-construction phase. Ginkgo invokes every container body exactly once to discover the structure of your suite. It collects β€” but does not run β€” the closures you pass to setup and subject nodes. The result is a tree it flattens into a list of specs.
  2. Run phase. Ginkgo walks the flattened spec list (randomized, possibly in parallel) and, for each spec, runs its setup closures, then its one subject closure, then its cleanup closures.

Container bodies run at construction time. Setup/subject closures run later, at run time. The consequences you must internalize:

  • No assertions in container bodies. They'd run once during construction, with no spec active β€” not as part of any test. Put assertions in It or BeforeEach.
  • No initialization in container bodies. A variable set in a Describe body is set once, shared across every spec, and mutated by whichever spec runs first. Declare in the container, initialize in BeforeEach so every spec gets a pristine copy. β†’ ginkgo:writing-specs.
  • Loops that build specs run at construction time β€” that's how you generate specs dynamically, but it also means closure-captured loop variables and any data the loop reads must be available then, not in BeforeSuite. β†’ ginkgo:tables-and-dynamic-specs.

Spec independence β€” the assumption everything rests on

Ginkgo assumes every spec is independent. This is what lets it randomize order (--randomize-all), run specs in parallel across processes (-p), and run any subset (--focus/labels). The rule that keeps you honest: declare in container, initialize in setup. Deliberate cross-spec dependencies break randomization and parallelism β€” when you genuinely need ordering, say so explicitly with an Ordered container (β†’ ginkgo:ordering-and-flakes) rather than relying on definition order.

The Parallelism Model

Ginkgo's parallelism model is process-based: each process runs a subset of the specs, with no shared memory.

The node taxonomy at a glance

  • Containers β€” Describe, Context, When (identical; pick the one that reads best). Organize the tree.
  • Subjects β€” It, Specify (identical). The actual test; contains the assertions.
  • Setup β€” BeforeEach/AfterEach (around every spec), JustBeforeEach/JustAfterEach (split configuration from creation), BeforeAll/AfterAll (once per Ordered container), BeforeSuite/AfterSuite (once per suite), SynchronizedBeforeSuite/SynchronizedAfterSuite (for common setup, then per-process setup when parallel). DeferCleanup registers teardown inline; DeferOnFailure registers failure-only diagnostics that run before teardown.
  • Reporting β€” ReportAfterEach/ReportAfterSuite etc. observe results. β†’ ginkgo:reporting.
  • Decorators β€” modifiers attached to any node: Serial, Ordered, Label, Focus, FlakeAttempts, SpecTimeout, … β†’ ginkgo:decorators.

Failures work by panic: Fail (which Gomega calls for you) panics; Ginkgo recovers it, records the failure, and runs cleanup. A goroutine that might fail needs defer GinkgoRecover() or its panic crashes the suite. β†’ ginkgo:timeouts-and-async.

Where to go next

  • Wiring Ginkgo into a project (bootstrap, RunSpecs, the CLI, dot-import alternatives) β†’ ginkgo:setup
  • Authoring specs (containers, subjects, setup/cleanup, the construction-time pitfalls) β†’ ginkgo:writing-specs
  • Table-driven and generated specs (DescribeTable, shared behaviors) β†’ ginkgo:tables-and-dynamic-specs
  • Looking up a decorator β†’ ginkgo:decorators
  • Running a subset (focus, skip, labels) β†’ ginkgo:filtering
  • Running in parallel / integration suites β†’ ginkgo:parallelism
  • **Ordered containers and fl
FAQ

What is Ginkgo?

Ginkgo is a testing framework for the Go programming language that uses a readable, sentence-like style.

Does this skill write tests for me?

It gives the background needed to guide test writing, and other guides in the same set cover the details.

Should I use the ginkgo command?

The skill recommends the ginkgo command-line tool over the standard go test command.

Details

Original description by the author

The Ginkgo mental model for writing Go tests β€” the one idea that explains everything (Ginkgo builds a spec tree at construction time, then runs it) and its consequences for how you write specs, plus spec independence and the node taxonomy. Use this first when you start working with Ginkgo in a project, or to decide how to approach a Ginkgo task. Routes to the other ginkgo:* skills.

repo: onsi/ginkgo

Popularity

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

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills