Why does Ginkgo mark skipped specs as failed instead of skipped?

While using Ginkgo for testing in Go, you might notice that when a suite is skipped inside a BeforeSuite, it still counts as a failure in the test summary.

For example:

ginkgo.BeforeSuite(func() {
    if !CheckCondition() {
        ginkgo.Skip("condition not available")
    }
})

When the condition isn’t met, the suite shows this result:

FAIL! -- 0 Passed | 1 Failed | 0 Pending | 0 Skipped

You might expect the skipped suite to be marked as skipped, not failed.

This happens because Skip in BeforeSuite doesn’t apply to individual specs - it affects the entire suite initialization, which Ginkgo interprets as a setup failure, not a skipped spec.

To truly skip tests, consider using BeforeEach with conditional skipping or wrapping your specs with an if check so that the specs themselves are skipped gracefully rather than the suite setup.

I ran into the same issue when trying to skip a suite inside BeforeSuite. Turns out, Ginkgo treats anything in BeforeSuite as part of setup - so if it doesn’t complete (even due to Skip), the framework marks it as a failed initialization, not a skipped test.

What worked for me was moving the condition check inside a BeforeEach or wrapping the actual specs with an if !CheckCondition() guard. That way, Ginkgo sees the specs themselves as “skipped,” not the whole suite.