filtering
できること
このスキルは、Ginkgoのテストの一部だけを実行するさまざまな方法を説明します。一部のグループを実行し、ほかをスキップし、準備ができていないテストに印を付けたい開発者向けです。
使う場面
- ✓大きなGinkgoのテストスイートの一部だけを実行したいとき。
- ✓まだ準備ができていないテストを、今はスキップしたいとき。
- ✓slowやintegrationなど、特定のラベルのテストだけを実行したいとき。
スキルのリンク
https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/filtering/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“integrationのラベルが付いたGinkgoテストだけを実行し、保留のマークが付いたものはスキップしてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、コンパイル時の保留マーク、実行時のスキップ、フォーカス、ラベルフィルター、名前フィルターから選びます。一部のオプションは他を上書きするため、それらがどう組み合わさるかも説明します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Filtering specs: running a subset
Ginkgo offers many ways to run fewer specs — ad-hoc (Pending/Skip/Focus) and structured (labels, semver, file/description filters). They combine by a strict precedence (see bottom). Decorator specifics live in ginkgo:decorators; label-driven CI in ginkgo:ci. Docs: https://onsi.github.io/ginkgo/#filtering-specs.
Pending — compile-time skip, uncoercible
Marks a spec/container as under development. Nothing can override Pending and make it run — not focus, not labels.
It("needs work", Pending, func() { ... })
It("placeholder", Pending) // pending specs need no closure
PDescribe("not ready", func() { ... }) // == Describe(..., Pending); X-prefix is identical
PIt(...) / XIt(...) / PEntry(...)
Pending specs don't fail the suite. ginkgo --fail-on-pending makes them fail CI — a policy that pending specs shouldn't be committed. Pending is compile-time only; you cannot make a spec pending at runtime — for that, use Skip.
Skip — runtime skip
Call Skip("reason") from any subject or setup node to skip during the run phase. It panics to halt the spec (like Fail) and records the reason; it does not fail the suite (even skipping every spec passes).
It("if it can", func() {
if !someCondition { Skip("special condition wasn't met") }
...
})
Scope matters: in a BeforeEach it skips the current spec; in a BeforeAll it skips all specs in the Ordered container; in a BeforeSuite it skips the entire suite. You cannot call Skip in a container body — it only applies during the run phase.
Focus — programmatic, for iterating (don't commit it)
When any spec is focused, Ginkgo runs only focused specs.
FIt("just me", func() { ... }) // or It(..., Focus, ...)
FDescribe(...) / FContext(...) / FEntry(...)
Child focus unfocuses focused ancestors. F an inner It inside an FDescribe and only that It runs — matches how you narrow while debugging.
The danger: committing focus breaks CI quietly-loudly. A passing suite with programmatic focus exits non-zero (logs say it succeeded but flags focused specs) so CI catches it. Strip them all with ginkgo unfocus (removes F prefixes and Focus decorators).
Labels and --label-filter
Label("a", "b") (→ ginkgo:decorators) tags container/subject nodes; a spec's labels are the union down its hierarchy. No &|!,()/" chars in a label. Filter with ginkgo --label-filter=QUERY:
| Operator | Meaning |
|---|---|
&& |
AND |
| ` | |
! |
NOT |
() |
grouping |
/regexp/ |
regex match against labels |
Bare words match label literals — case-insensitive, whitespace-trimmed.
ginkgo --label-filter="network && !slow"
ginkgo --label-filter="integration, smoke" # comma == ||
ginkgo --label-filter=/library/ # regex
Consistent labelling is a best-practice for maintainable filtering.
Label sets — KEY:VALUE
A label KEY:VALUE adds VALUE to set KEY (multiple values accumulate, e.g. Label("API:Library", "API:Geo") → API = {Library, Geo}). Filter with KEY: OP <arg> where arg is a single value or {V1, V2}:
| Op | Matches when set KEY… |
|---|---|
isEmpty |
has no KEY:* labels |
containsAny |
contains any arg element |
containsAll |
contains all arg elements |
consistsOf |
equals exactly the args |
isSubsetOf |
is a subset of args — note: an empty set always matches |
ginkgo --label-filter="integration && !slow && Readiness: isSubsetOf {Beta, RC}"
ginkgo --label-filter="API: consistsOf {Library, Geo}"
Set values are literals (no regex). Prefer sets over regexes for structured filtering.
- Suite-level labels:
RunSpecs(t, "Books Suite", Label("books"))apply to the whole suite — filter out entire suites. - Runtime check:
Label("perf").MatchesLabelFilter(GinkgoLabelFilter())lets a spec branch on the active--label-filter(GinkgoLabelFilter()returns it). - Discover/iterate:
ginkgo labelslists labels in a package;ginkgo --dry-run -v --label-filter=Qshows what a filter selects without running.
SemVer filtering
SemVerConstraint(">= 3.2.0") (and ComponentSemVerConstraint("redis", ">= 8.0.0")) gate specs by version; run with --sem-ver-filter. Constraints follow Masterminds/semver (~, ^, comma-ANDed). Hierarchical: child constraints *narrow
よくある質問
保留のテストを強制的に実行できますか?
いいえ。保留のマークは何によっても上書きできないため、そのテストはスキップされたままです。
保留とスキップの違いは何ですか?
保留はコンパイル時に設定され、スキップは実行中に判断されます。
保留のテストはビルドを失敗させますか?
デフォルトではさせません。ただし、保留が残っていればCIを失敗させる設定があります。
詳細
作者による元の説明
Run a subset of a Ginkgo suite — Pending/PIt/XIt, runtime Skip, programmatic Focus/FIt (and ginkgo unfocus), Label with the --label-filter query language and label sets, suite-level labels, SemVerConstraint/--sem-ver-filter, --focus/--skip and --focus-file/--skip-file, the filtering precedence rules, and --fail-on-pending/--fail-on-empty. Use when you want to run, skip, focus, label, or version-gate specs, or debug why specs were or weren't selected.
repo: onsi/ginkgo
人気
- GitHubのスター
- 9.1k
- ランキング
- #12301
- ライセンス
- MIT
- 更新日
- 2026/10/9
コメント
- …
このリポジトリの他のスキル
ci
9.1kエージェントが、GinkgoのテストをCIで確実に動かせるよう設定を支援します。保留やフォーカスの取り残し、不安定なテストを見つける推奨フラグも含みます。
debugging-failures
9.1kエージェントが、要約の一行を読み、JSONレポートから失敗したテストとメッセージを取り出して、Ginkgoのテストが失敗した理由を見つけられるよう支援します。
decorators
9.1kエージェントが、Serial、Ordered、Label、Focus、タイムアウトなどのGinkgoのテストのデコレーターを、それぞれの働きを説明しながら正しく使えるよう支援します。
ordering-and-flakes
9.1kエージェントが、GinkgoのSerialとOrderedの設定と再試行オプションを使い、Goのテストの実行順序と不安定なテストを管理できるよう支援します。
似ているスキル
test-driven-development
311k機能や修正を作る前に、まず失敗するテストを書き、それが失敗するのを確認してから、合格させる最小のコードを書くようエージェントに教えます。
verification-before-completion
311kタスク、修正、ビルドが完了した、または合格したと主張する前に、実際のチェックを実行し、その出力を読むようエージェントに教えます。
migrate-to-shoehorn
310kテストファイル内の危険な型キャストを、shoehornライブラリに置き換え、テストが部分的なデータを使いつつ型チェックを通るようにします。