ordering-and-flakes
Что он делает
Этот скилл объясняет, как запускать тесты Ginkgo в фиксированном порядке и как работать с тестами, которые иногда падают. Он нужен разработчикам, которые пишут тесты на Go с фреймворком Ginkgo.
Когда использовать
- ✓Когда набор тестов Go должен запускаться в фиксированном порядке.
- ✓Когда тест Ginkgo падает только иногда и его нужно проверить или повторить.
- ✓Когда вы хотите найти тесты, которые зависят от порядка запуска.
Ссылка на скилл
https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/ordering-and-flakes/SKILL.mdСкопируйте и вставьте её в ваш ИИ (Claude, ChatGPT или Cursor) с просьбой следовать инструкциям.
Как использовать
Самый простой способ: скопируйте сообщение и вставьте его в свой ИИ. Он прочитает скилл и выполнит инструкции.
Готовое сообщение для вставки
Для Claude Code, Codex или Cursor: запустите в папке проекта, и скилл установится.
Скачайте SKILL.md и положите его в папку скиллов вашего агента.
Пример запроса к вашему ИИ
“Наши тесты Go падают случайно. Можешь сделать так, чтобы нестабильные тесты в Ginkgo работали надёжно?”
5 новых скиллов в неделю. 1 минута чтения.
Как это работает
Скилл показывает, какие настройки Ginkgo заставляют тесты идти один за другим, а какие повторяют или перезапускают тест, чтобы выявить нестабильное поведение.
Технический текст (оригинальный SKILL.md)
Оригинальный текст автора на английском, прямо с GitHub.
Ordering and flakes
Two topics that share a root cause: specs that aren't truly independent (ginkgo:overview). Ordering decorators let you declare a dependency on purpose; flake controls let you manage or expose one. Docs: https://onsi.github.io/ginkgo/#serial-specs, https://onsi.github.io/ginkgo/#ordered-containers, https://onsi.github.io/ginkgo/#repeating-spec-runs-and-managing-flaky-specs.
Serial: opt out of parallelism
Serial (container or subject) guarantees a spec never runs in parallel with anything else. Under the hood Ginkgo runs serial specs last, on process #1, after every other process has finished its suite. Reach for it sparingly. OK for benchmarks, resource hogs, or specs that put an external resource into a known-bad state - but not OK as a band-aid for order-dependence or poorly isolated code/specs.
Describe("Something expensive", Serial, func() {
It("is a resource hog that can't share the box", func() { ... })
})
→ ginkgo:decorators, ginkgo:parallelism.
Ordered: run specs in definition order
Ordered (container only) guarantees its child specs run sequentially, in written order, on one process — so they may legitimately mutate shared closure state. They can still parallelize against specs in other containers; only the inner order is pinned.
Describe("checking out a book", Ordered, func() {
var libraryClient *library.Client
var book *books.Book
BeforeAll(func() { // once, before the first spec
libraryClient = library.NewClient()
Expect(libraryClient.Connect()).To(Succeed())
DeferCleanup(libraryClient.Disconnect) // context-aware: behaves like AfterAll
DeferOnFailure(libraryClient.DumpState) // covers EVERY spec in this container; runs before teardown
})
It("can fetch a book", func() { book, _ = libraryClient.FetchByTitle("Les Miserables") })
It("can check it out", func() { Expect(library.CheckOut(book)).To(Succeed()) })
It("is then out of stock", func() { ... })
AfterAll(func() { ... }) // once, after the last spec
})
BeforeAll/AfterAllare legal only inside anOrderedcontainer (or a container nested within one). That's the whole point ofOrdered— once-per-group expensive setup.- A failing spec skips the rest of the group by default (then
AfterAllstill runs). Spec independence is gone, so Ginkgo won't pretend the later specs are meaningful. ContinueOnFailure(outermostOrderedonly — error on a nested container) overrides that: keep running later specs after a failure. Use it whenOrderedis just shared setup, not a dependent flow. A failedBeforeAllstill skips everything — the setup is presumed broken.- Nested containers inside an
Orderedcontainer are automaticallyOrdered; there's no way to un-order them.
OncePerOrdered: outer *Each setup that respects groups
A top-level BeforeEach that resets state runs before every spec — which breaks an Ordered group's first-spec-sets-up-rest contract (spec 1 passes, the rest get wiped). Decorate it with OncePerOrdered so it runs once per independent unit: still per-spec for normal specs, but once around each Ordered container (like a BeforeAll).
BeforeEach(OncePerOrdered, func() {
libraryClient = library.NewClient()
snapshot := libraryClient.TakeSnapshot()
DeferCleanup(libraryClient.RestoreSnapshot, snapshot)
})
Applies to BeforeEach/JustBeforeEach/AfterEach/JustAfterEach only — not ReportBeforeEach/ReportAfterEach (reporting is always per-spec).
The Serial-inside-Ordered gotcha
You cannot mark an individual spec inside an Ordered container Serial. To make a whole ordered group run serially, put both decorators on the container: Describe("...", Ordered, Serial, func(){...}).
Ordered vs one big It
Ordered and a single It with By steps (ginkgo:writing-specs) solve the same "dependent flow" problem. Prefer one It + By by default — it stays fully parallelizable and independent. Reach for Ordered when you want each step reported as its own spec, or genuinely need BeforeAll once-per-group setup. Either way, use Ordered only when needed — it gives up internal parallelism.
SpecPriority
SpecPriority(int) (default 0, higher runs earlier, may be negative) is a scheduling hint — e.g. "boulders first, then sand" in big suites. Honored per-spec under --randomize-all, otherwise per outermost
Частые вопросы
Меняет ли это скорость тестов?
Да, запуск в фиксированном порядке или по одному может замедлить тесты, потому что они не могут идти все сразу.
Нужно ли знать Go, чтобы использовать это?
Да, скилл посвящён тестам на Go, поэтому нужен проект на Go, использующий Ginkgo.
Может ли он помочь найти тесты, зависящие друг от друга?
Да, он описывает, как повторять запуски и проверять зависимость от порядка.
Подробности
Оригинальное описание автора
Control spec ordering and manage flaky specs — Serial, Ordered containers with BeforeAll/AfterAll/ContinueOnFailure, OncePerOrdered, SpecPriority, plus FlakeAttempts/--flake-attempts, MustPassRepeatedly, --repeat, and --until-it-fails. Use when specs must run in a fixed order, you need once-per-group setup, you're combining Serial+Ordered, a spec is flaky, or you want to hunt order-dependence with --until-it-fails -p --randomize-all.
repo: onsi/ginkgo
Популярность
- Звёзды на GitHub
- 9.1k
- Место в рейтинге
- #12302
- Лицензия
- MIT
- Обновлён
- 09.10.2026
Комментарии
- …
Другие скиллы из этого репозитория
ci
9.1kПомогает агенту настроить тесты Ginkgo для непрерывной интеграции с рекомендуемыми флагами, которые ловят оставленные метки focus и pending, а также нестабильные тесты.
debugging-failures
9.1kПомогает агенту понять, почему тесты Ginkgo упали: он читает строку с итогом и достаёт точные падающие тесты и сообщения из JSON-отчёта.
decorators
9.1kПомогает агенту правильно использовать декораторы тестов Ginkgo, например Serial, Ordered, Label, Focus и таймауты, объясняя, что делает каждый из них.
filtering
9.1kПомогает агенту запускать только часть тестов Ginkgo, используя pending, skip, focus, метки, ограничения версий и фильтры по файлам в правильном порядке приоритетов.
Похожие скиллы
test-driven-development
311kУчит агента сначала писать падающий тест, увидеть, что он падает, и только затем писать минимальный код, который его проходит, прежде чем создавать любую функцию или исправление.
verification-before-completion
311kУчит агента запускать настоящие проверки и читать их вывод, прежде чем утверждать, что задача, исправление или сборка готовы или проходят.
migrate-to-shoehorn
310kЗаменяет рискованные приведения типов в тестовых файлах на библиотеку shoehorn, чтобы тесты могли использовать неполные данные и проходить проверку типов.