filtering
Fungsinya
Skill ini menjelaskan banyak cara untuk menjalankan sebagian tes Go Ginkgo. Skill ini ditujukan untuk pengembang yang ingin menjalankan satu grup, melewati yang lain, atau menandai tes yang belum siap.
Kapan dipakai
- βSaat Anda ingin menjalankan hanya satu bagian dari rangkaian tes Ginkgo yang besar.
- βSaat sebuah tes belum siap dan sebaiknya dilewati untuk sementara.
- βSaat Anda ingin menjalankan tes dengan label tertentu, seperti slow atau integration.
Link skill
https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/filtering/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βJalankan hanya tes Ginkgo yang berlabel integration, dan lewati apa pun yang ditandai pending.β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent memilih antara penanda pending saat kompilasi, skip saat berjalan, focus, filter label, dan filter nama, lalu menjelaskan cara kombinasinya, karena beberapa opsi menimpa opsi lain.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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
Pertanyaan umum
Bisakah tes yang tertunda dipaksa berjalan?
Tidak. Tidak ada yang bisa menimpa penanda pending, jadi tes itu tetap dilewati.
Apa bedanya pending dan skip?
Pending ditetapkan saat kompilasi, sedangkan skip diputuskan saat tes berjalan.
Apakah tes yang tertunda membuat build gagal?
Tidak secara bawaan, tetapi opsi gagal-jika-tertunda membuat CI gagal jika ada tes seperti itu.
Detail
Deskripsi asli dari pembuat
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
Popularitas
- Bintang GitHub
- 9.1k
- Peringkat
- #12301
- Lisensi
- MIT
- Diperbarui
- 9/10/2026
Komentar
- β¦
Skill lain dari repositori ini
ci
9.1kMembantu agent Anda menyiapkan tes Ginkgo untuk integrasi berkelanjutan, dengan flag yang direkomendasikan untuk menangkap penanda fokus atau tertunda yang tertinggal serta tes yang tidak stabil.
debugging-failures
9.1kMembantu agent Anda mencari tahu mengapa tes Ginkgo gagal dengan membaca baris ringkasan dan mengambil tes yang gagal beserta pesannya dari laporan JSON.
decorators
9.1kMembantu agent Anda memakai dekorator tes Ginkgo dengan benar, seperti Serial, Ordered, Label, Focus, dan batas waktu, dengan menjelaskan fungsi masing-masing.
ordering-and-flakes
9.1kMembantu agent Anda mengendalikan urutan tes Go dan menangani tes yang tidak stabil, dengan pengaturan Serial dan Ordered dari Ginkgo serta opsi percobaan ulang.
Skill serupa
test-driven-development
311kMengajari agent Anda menulis tes yang gagal dulu, melihatnya gagal, lalu menulis kode terkecil yang lulus, sebelum membangun fitur atau perbaikan apa pun.
verification-before-completion
311kMengajari agent Anda menjalankan pemeriksaan nyata dan membaca keluarannya sebelum menyatakan tugas, perbaikan, atau build sudah selesai atau lulus.
migrate-to-shoehorn
310kMengganti type cast berisiko di file tes Anda dengan pustaka shoehorn, sehingga tes bisa memakai data parsial dan tetap lulus pemeriksaan tipe.