MCPcopy Index your code
hub / github.com/onsi/ginkgo

github.com/onsi/ginkgo @v2.32.0

repository ↗ · DeepWiki ↗ · release v2.32.0 ↗ · + Follow
1,713 symbols 7,222 edges 412 files 268 documented · 16% 69 cross-repo links
README

Ginkgo

test | Ginkgo Docs


Ginkgo

Ginkgo is a mature testing framework for Go designed to help you write expressive specs. Ginkgo builds on top of Go's testing foundation and is complemented by the Gomega matcher library. Together, Ginkgo and Gomega let you express the intent behind your specs clearly:

import (
    . "github.com/onsi/ginkgo/v2"
    . "github.com/onsi/gomega"
    ...
)

var _ = Describe("Checking books out of the library", Label("library"), func() {
    var library *libraries.Library
    var book *books.Book
    var valjean *users.User
    BeforeEach(func() {
        library = libraries.NewClient()
        book = &books.Book{
            Title: "Les Miserables",
            Author: "Victor Hugo",
        }
        valjean = users.NewUser("Jean Valjean")
    })

    When("the library has the book in question", func() {
        BeforeEach(func(ctx SpecContext) {
            Expect(library.Store(ctx, book)).To(Succeed())
        })

        Context("and the book is available", func() {
            It("lends it to the reader", func(ctx SpecContext) {
                Expect(valjean.Checkout(ctx, library, "Les Miserables")).To(Succeed())
                Expect(valjean.Books()).To(ContainElement(book))
                Expect(library.UserWithBook(ctx, book)).To(Equal(valjean))
            }, SpecTimeout(time.Second * 5))
        })

        Context("but the book has already been checked out", func() {
            var javert *users.User
            BeforeEach(func(ctx SpecContext) {
                javert = users.NewUser("Javert")
                Expect(javert.Checkout(ctx, library, "Les Miserables")).To(Succeed())
            })

            It("tells the user", func(ctx SpecContext) {
                err := valjean.Checkout(ctx, library, "Les Miserables")
                Expect(err).To(MatchError("Les Miserables is currently checked out"))
            }, SpecTimeout(time.Second * 5))

            It("lets the user place a hold and get notified later", func(ctx SpecContext) {
                Expect(valjean.Hold(ctx, library, "Les Miserables")).To(Succeed())
                Expect(valjean.Holds(ctx)).To(ContainElement(book))

                By("when Javert returns the book")
                Expect(javert.Return(ctx, library, book)).To(Succeed())

                By("it eventually informs Valjean")
                notification := "Les Miserables is ready for pick up"
                Eventually(ctx, valjean.Notifications).Should(ContainElement(notification))

                Expect(valjean.Checkout(ctx, library, "Les Miserables")).To(Succeed())
                Expect(valjean.Books(ctx)).To(ContainElement(book))
                Expect(valjean.Holds(ctx)).To(BeEmpty())
            }, SpecTimeout(time.Second * 10))
        })  
    })

    When("the library does not have the book in question", func() {
        It("tells the reader the book is unavailable", func(ctx SpecContext) {
            err := valjean.Checkout(ctx, library, "Les Miserables")
            Expect(err).To(MatchError("Les Miserables is not in the library catalog"))
        }, SpecTimeout(time.Second * 5))
    })
})

Jump to the docs to learn more. It's easy to bootstrap and start writing your first specs.

If you have a question, comment, bug report, feature request, etc. please open a GitHub issue, or visit the Ginkgo Slack channel.

Capabilities

Whether writing basic unit specs, complex integration specs, or even performance specs - Ginkgo gives you an expressive Domain-Specific Language (DSL) that will be familiar to users coming from frameworks such as Quick, RSpec, Jasmine, and Busted. This style of testing is sometimes referred to as "Behavior-Driven Development" (BDD) though Ginkgo's utility extends beyond acceptance-level testing.

With Ginkgo's DSL you can use nestable Describe, Context and When container nodes to help you organize your specs. BeforeEach and AfterEach setup nodes for setup and cleanup. It and Specify subject nodes that hold your assertions. BeforeSuite and AfterSuite nodes to prep for and cleanup after a suite... and much more!.

At runtime, Ginkgo can run your specs in reproducibly random order and has sophisticated support for spec parallelization. In fact, running specs in parallel is as easy as

ginkgo -p

By following established patterns for writing parallel specs you can build even large, complex integration suites that parallelize cleanly and run performantly. And you don't have to worry about your spec suite hanging or leaving a mess behind - Ginkgo provides a per-node context.Context and the capability to interrupt the spec after a set period of time - and then clean up.

As your suites grow Ginkgo helps you keep your specs organized with labels and lets you easily run subsets of specs, either programmatically or on the command line. And Ginkgo's reporting infrastructure generates machine-readable output in a variety of formats and allows you to build your own custom reporting infrastructure.

Ginkgo ships with ginkgo, a command line tool with support for generating, running, filtering, and profiling Ginkgo suites. You can even have Ginkgo automatically run your specs when it detects a change with ginkgo watch, enabling rapid feedback loops during test-driven development.

And that's just Ginkgo! Gomega brings a rich, mature, family of assertions and matchers to your suites. With Gomega you can easily mix synchronous and asynchronous assertions in your specs. You can even build your own set of expressive domain-specific matchers quickly and easily by composing Gomega's existing building blocks.

Happy Testing!

Using Ginkgo with Claude Code

Ginkgo ships a set of Claude Code skills as a plugin, with this repo doubling as the marketplace, so an agent writing specs in your project has Ginkgo's idioms, decorators, and gotchas on hand. From inside Claude Code:

/plugin marketplace add onsi/ginkgo
/plugin install ginkgo@ginkgo

(or non-interactively: claude plugin marketplace add onsi/ginkgo then claude plugin install ginkgo@ginkgo)

This installs a family of ginkgo:* skills that activate automatically while you write and run specs. Start with ginkgo:overview; see the plugin README for the full list.

License

Ginkgo is MIT-Licensed

Contributing

See CONTRIBUTING.md

Sponsors

Sponsors commit to a sponsorship for a year. If you're an organization that makes use of Ginkgo please consider becoming a sponsor!

Browser testing via

Extension points exported contracts — how you extend this code

TimelineEvent (Interface)
TimelineEvent represent an event on the timeline consumers of Timeline will need to check the concrete type of each entr [5 …
types/types.go
GinkgoTestingT (Interface)
The interface by which Ginkgo receives *testing.T [3 implementers]
core_dsl.go
ColorableStringer (Interface)
ColorableStringer is an interface that ReportEntry values can satisfy. If they do then ColorableString() is used to gen [3 …
types/report_entry.go
OutputInterceptor (Interface)
* The OutputInterceptor is used by to intercept and capture all stdin and stderr output during a test run. */ [3 implementers]
internal/output_interceptor.go
DeprecatedReporter (Interface)
Deprecated: DeprecatedReporter was how Ginkgo V1 provided support for CustomReporters this has been removed in V2. Pleas [2 …
reporters/deprecated_reporter.go
GinkgoTInterface (Interface)
* The portion of the interface returned by GinkgoT() that maps onto methods in the testing package's T. */ [1 implementers]
ginkgo_t_dsl.go
Reporter (Interface)
(no doc) [3 implementers]
reporters/reporter.go
Benchmarker (Interface)
* Deprecated: Benchmarker has been removed from Ginkgo 2.0 Use Gomega's gmeasure package instead. You can learn more he
deprecated_dsl.go

Core symbols most depended-on inside this repo

It
called by 1855
core_dsl.go
T
called by 951
internal/test_helpers/run_tracker.go
Describe
called by 623
core_dsl.go
Entry
called by 568
table_dsl.go
BeforeEach
called by 550
core_dsl.go
Find
called by 359
internal/test_helpers/fake_reporter.go
Label
called by 179
decorator_dsl.go
AfterEach
called by 159
core_dsl.go

Shape

Method 826
Function 594
Struct 166
TypeAlias 89
Interface 22
FuncType 16

Languages

Go100%

Modules by API surface

types/types.go81 symbols
internal/node.go76 symbols
types/errors.go71 symbols
ginkgo_t_dsl.go68 symbols
core_dsl.go54 symbols
internal/testingtproxy/testing_t_proxy.go53 symbols
internal/test_helpers/fake_reporter.go48 symbols
internal/suite.go34 symbols
internal/output_interceptor.go34 symbols
types/config.go32 symbols
reporters/default_reporter.go31 symbols
reporters/default_reporter_test.go30 symbols

Dependencies from manifests, versioned

github.com/Masterminds/semver/v3v3.4.0 · 1×
github.com/gkampitakis/ciinfov0.3.2 · 1×
github.com/gkampitakis/go-diffv1.3.2 · 1×
github.com/gkampitakis/go-snapsv0.5.15 · 1×
github.com/go-logr/logrv1.4.3 · 1×
github.com/go-task/slim-sprig/v3v3.0.0 · 1×
github.com/goccy/go-yamlv1.18.0 · 1×
github.com/google/pprofv0.0.0-2026040205171 · 1×
github.com/joshdk/go-junitv1.0.0 · 1×
github.com/kr/prettyv0.3.1 · 1×

For agents

$ claude mcp add ginkgo \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact