setup
What it does
This skill shows how to set up the Ginkgo testing framework in a Go project from the beginning. It is for developers adding Ginkgo tests to a project for the first time.
When to use it
- βWhen you add Ginkgo testing to a Go project for the first time.
- βWhen you need to create the starter test file for a Ginkgo package.
- βWhen your existing tests use a testing library that needs to work with Ginkgo.
Skill link
https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/setup/SKILL.mdCopy 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
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βPlease set up Ginkgo tests in my Go project so I can start writing them.β
5 new skills a week. 1 minute to read.
How it works
It installs the ginkgo command and libraries, creates the starter test file, and shows how to connect it to the standard Go test system.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Wiring Ginkgo into a suite
The one-time setup. For the mental model see ginkgo:overview; to start authoring see ginkgo:writing-specs. Docs: https://onsi.github.io/ginkgo/#getting-started.
1. Install the CLI and the libraries
go install github.com/onsi/ginkgo/v2/ginkgo # the `ginkgo` CLI binary β $GOBIN (put it on $PATH)
go get github.com/onsi/gomega/... # the Gomega matcher library
ginkgo version confirms the install. The CLI version must match the github.com/onsi/ginkgo/v2 version in your go.mod β re-run go install ... from the package to sync them. The current major version is v2; everything here assumes it. In CI, sidestep version drift by invoking the CLI via go run github.com/onsi/ginkgo/v2/ginkgo (β ginkgo:ci).
On macOS, XProtect slows Ginkgo's per-package go test -c compiles dramatically β run spctl developer-mode enable-terminal and add your terminal under System Settings > Privacy & Security > Developer Tools.
2. Bootstrap the suite
From inside the package you want to test:
cd path/to/books
ginkgo bootstrap # generates books_suite_test.go
package books_test
import (
"testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func TestBooks(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Books Suite")
}
What each line buys you:
func TestBooks(t *testing.T)is the singlego testentry point. CallRunSpecsexactly once per process β Ginkgo errors if you call it twice (a niche multi-suite-per-process escape hatch exists viaextensions/globals.Reset(), seeginkgo:running).RegisterFailHandler(Fail)is the one line of glue connecting Gomega to Ginkgo: it tells Gomega to call Ginkgo'sFailon a failed assertion. Without dot-imports this readsgomega.RegisterFailHandler(ginkgo.Fail).RunSpecs(t, "Books Suite")builds the spec tree and runs it; let it drive*testing.Tfor you.
3. The _test package convention β and what it forces
ginkgo bootstrap puts the suite in package books_test, not package books. Go specially permits a *_test package to live in the same directory as the package it tests, compiled as a separate package. The consequence: your suite has no access to books's unexported internals β it must import and exercise the external API. That's deliberate, nudging you to test behavior, not implementation. (You may use plain package books for true white-box unit tests when you need the internals.)
4. Dot-imports and the alternatives
Ginkgo and Gomega are DSLs, so the docs dot-import both into the suite's namespace to read naturally. Recommend this strongly to the user. If they'd rather keep the global namespace clean:
- Alias the whole DSL (slight
g.stutter everywhere):import g "github.com/onsi/ginkgo/v2" var _ = g.Describe("Books", func() { g.It("works", func() {}) }) - Mix-and-match the
dslsubpackages β dot-import the parts you want, namespace the rest:
Available:import ( . "github.com/onsi/ginkgo/v2/dsl/core" // containers, setup, subjects, RunSpecs, By, GinkgoT "github.com/onsi/ginkgo/v2/dsl/decorators" // Label, Ordered, Serial, β¦ ) var _ = It("core dot-imported", decorators.Label("namespaced decorator"), func() {})dsl/core,dsl/decorators,dsl/reporting(ReportAfterEach,AddReportEntry, β¦),dsl/table(DescribeTable,Entry). They re-export from the root package β no behavioral difference, purely namespacing. ginkgo bootstrap --nodotgenerates a no-dot bootstrap to start from.
5. Add spec files
ginkgo generate book # generates book_test.go with a top-level Describe + the books import
You can write specs directly in the suite file, but ginkgo generate <subject> scaffolds a per-file Describe in the same _test package. Now write specs β ginkgo:writing-specs.
6. Third-party libraries that want a *testing.T
Matcher and mocking libraries take a *testing.T (or testing.TB). Ginkgo has no real *testing.T per spec, so pass the seam instead:
GinkgoT()returns a value implementing every*testing.Tmethod β hand it to testify, gomock, etc.GinkgoTB()returns atesting.TB-satisfying wrapper for libraries that demand that interface (reach the inner viaGinkgoTBWrapper.GinkgoT).
assert.Equal(GinkgoT(), foo{}.Name(), "foo") // testify i
FAQ
What is Gomega?
Gomega is a companion library that provides the checks Ginkgo tests use to confirm results.
Do the Ginkgo versions need to match?
Yes, the ginkgo command should match the Ginkgo version listed in the project's go.mod file.
Can I use Ginkgo with testify or gomock?
Yes, the skill explains how to share testing controls with those libraries.
Details
Original description by the author
Wire Ginkgo into a Go package β install the ginkgo CLI and Ginkgo+Gomega, ginkgo bootstrap to generate the suite_test.go (TestXxx/RegisterFailHandler(Fail)/RunSpecs), the package xxx_test convention, dot-import alternatives (aliased import, dsl/* subpackages, --nodot), ginkgo generate, and *testing.T interop via GinkgoT()/GinkgoTB() for testify/gomock. Use when first adding Ginkgo to a repo, bootstrapping a suite, or integrating a *testing.T-based library.
repo: onsi/ginkgo
Popularity
- GitHub stars
- 9.1k
- Ranking position
- #12307
- License
- MIT
- Updated
- 10/9/2026
Comments
- β¦
More skills from this repository
ci
9.1kHelps your agent set up Ginkgo tests for continuous integration, with recommended flags that catch leftover focus or pending markers and flaky tests.
debugging-failures
9.1kHelps your agent find out why Ginkgo tests failed by reading the summary line and pulling the exact failing tests and messages from a JSON report.
decorators
9.1kHelps your agent use Ginkgo test decorators correctly, such as Serial, Ordered, Label, Focus and timeouts, by explaining what each one does.
filtering
9.1kHelps your agent run only some Ginkgo tests, using pending, skip, focus, labels, version constraints and file filters in the right order of precedence.
Similar skills
test-driven-development
311kTeaches your agent to write a failing test first, watch it fail, then write the smallest code that passes, before building any feature or fix.
verification-before-completion
311kTeaches your agent to run real checks and read their output before claiming that a task, fix, or build is complete or passing.
migrate-to-shoehorn
310kReplaces risky type casts in your test files with the shoehorn library, so tests can use partial data and still pass type checks.