debugging-failures
Skill này làm gì
Skill này chỉ cách tìm ra lý do các bài kiểm thử Go Ginkgo bị lỗi, mà không cần đọc các log dài. Nó dành cho lập trình viên và agent cần chi tiết lỗi rõ ràng một cách nhanh chóng.
Khi nào nên dùng
- ✓Khi một bộ kiểm thử Ginkgo bị lỗi và bạn cần biết bài nào lỗi và vì sao.
- ✓Khi đầu ra kiểm thử bị lẫn lộn vì các bài chạy song song.
- ✓Khi bạn muốn chạy lại một bài kiểm thử lỗi với cùng thứ tự ngẫu nhiên.
Liên kết skill
https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/debugging-failures/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Các bài kiểm thử Ginkgo của tôi bị lỗi. Tìm chính xác bài nào đã lỗi và vì sao.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent chạy bộ kiểm thử một lần với báo cáo JSON, đọc kết quả một dòng, rồi dùng một bộ lọc để chỉ lấy các bài thất bại, thông báo của chúng, vị trí file và log đã ghi. Nó có thể chạy lại với cùng seed để tái hiện lỗi.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Debugging Ginkgo failures (especially as an agent)
Ginkgo's terminal output is good for a human; for programmatic diagnosis, prefer a hybrid: terminal for the verdict, JSON + jq for the details. This is empirically the most reliable, lowest-token workflow. Docs: https://onsi.github.io/ginkgo/#reporting-and-profiling-suites.
The workflow: one run, JSON-first diagnosis
# One invocation gives you BOTH the human verdict on the terminal AND a structured report.
# --json-report does NOT suppress console output, so you don't pay for two runs.
ginkgo -r -p --no-color --json-report=report.json --output-dir=.ginkgo-report
- Read the terminal tail for the one-line verdict:
FAIL! -- 5 Passed | 6 Failed | 1 Pending | 1 Skipped. Cheap, immediate. - If there are failures, query the JSON with
jq(filters below) to get exactly the failing specs — stable, addressable, order-independent. - Clean up the report dir when done.
Why hybrid and not one or the other:
- Terminal-only is brittle to parse (free-form text) and, under
-p, interleaves failures in nondeterministic order. - JSON-only is wasteful if you dump it: the full
report.jsonis ~9× the tokens of the terminal output. Ajqfailures-only extraction is a fraction of either. The discipline is filter, don't dump.
Where the JSON lands (use --output-dir deliberately)
--json-report=report.jsonalone writesreport.jsonto the current directory — which scatters into package dirs under-rand risks getting committed.- Prefer
--output-dir=DIRto collect everything in one known place (auto-created). With-r, all suites merge into oneDIR/report.json— ideal: one file, one set ofjqfilters. - Use a gitignored or temp location: a repo-local
.ginkgo-report/(add it to.gitignore) or an absolute temp path (--output-dir=/tmp/ginkgo-report). Don't leavereport.jsonin the working tree. --keep-separate-reports(with-r) writes onePACKAGE_report.jsonper package instead of merging — only reach for it when you must attribute failures per package.
The jq filters (tested against the real schema)
The report is an array of suite reports, each with a .SpecReports[] array.
Verdict / counts per suite:
jq -r '.[] | "\(.SuiteDescription): \([.SpecReports[].State]|group_by(.)|map("\(length) \(.[0])")|join(", "))"' .ginkgo-report/report.json
All failures — name, location, message (the workhorse). Select failed and panicked and timedout — see the trap below:
jq -r '.[].SpecReports[]
| select(.State=="failed" or .State=="panicked" or .State=="timedout")
| "[\(.State|ascii_upcase)] \((.ContainerHierarchyTexts+[.LeafNodeText])|join(" > "))\n \(.Failure.Location.FileName):\(.Failure.Location.LineNumber)\n \(.Failure.Message)"' .ginkgo-report/report.json
Panics — the real user-code line (the headline location lies; see below):
jq -r '.[].SpecReports[] | select(.State=="panicked")
| "PANIC: \(.Failure.ForwardedPanic)\n\(.Failure.Location.FullStackTrace)"' .ginkgo-report/report.json
Drill into one spec by name, with its captured logs:
jq -r '.[].SpecReports[] | select(.LeafNodeText|test("SUBSTRING"))
| "STATE: \(.State)\n\(.Failure.Message)\n--- GinkgoWriter ---\n\(.CapturedGinkgoWriterOutput // "(none)")"' .ginkgo-report/report.json
Slowest specs:
jq '.[0].SpecReports | map([(.ContainerHierarchyTexts+[.LeafNodeText])|join(" "), .RunTime/1e9]) | sort_by(.[1]) | reverse | .[0:10]' .ginkgo-report/report.json
Schema facts you need
State:passed | failed | panicked | pending | skipped | timedout | interrupted | aborted.- Spec name =
ContainerHierarchyTexts(array) +LeafNodeText. Failure.Message— the failure text (Gomega's full expected/got block for assertions).Failure.Location.{FileName,LineNumber,FullStackTrace}.Failure.ForwardedPanic— the panic value (only meaningful forpanicked).Failure.FailureNodeType— e.g.BeforeEachvsIt, so you know a setup node failed.CapturedGinkgoWriterOutput—GinkgoWriterlogs (omitted if empty).SpecEvents[]—By(...)steps and node enter/exit (does not include raw GinkgoWriter text).ParallelProcess— which worker ran the spec (-p).AdditionalFailures[]— failures beyond the primaryFailure(e.g. a failingAfterEachorDeferOnFailurecallback). Usually the primary is
Câu hỏi thường gặp
Vì sao không đọc toàn bộ log?
Khi chạy song song, thông báo lỗi có thể bị lẫn lộn, và báo cáo đầy đủ lớn hơn nhiều, nên skill lọc để lấy chi tiết.
Seed là gì?
Đó là con số thiết lập thứ tự kiểm thử ngẫu nhiên, và dùng lại nó sẽ tái tạo đúng lượt chạy đó.
Nó có dọn các file báo cáo không?
Có. Skill kết thúc bằng việc xóa thư mục báo cáo khi chẩn đoán đã xong.
Chi tiết
Mô tả gốc của tác giả
Diagnose a failing Ginkgo suite as an agent — always run with --json-report into a predictable temp/gitignored location, read the terminal verdict line, then use jq to extract structured failure details (name, message, file:line, panic value, captured logs). Covers the panicked-vs-failed trap, panic locations pointing into the Go runtime, parallel output interleaving, reproducing with --seed, and progress reports for hangs. Use when a suite failed and you need to know why. Also invokable as /ginkgo:debugging-failures.
repo: onsi/ginkgo
Độ phổ biến
- Sao GitHub
- 9.1k
- Vị trí xếp hạng
- #12299
- Giấy phép
- MIT
- Cập nhật
- 9/10/2026
Bình luận
- …
Thêm skill từ kho mã này
ci
9.1kGiúp agent của bạn thiết lập kiểm thử Ginkgo cho CI, với các cờ khuyến nghị để bắt dấu focus hoặc pending còn sót và bài kiểm thử không ổn định.
decorators
9.1kGiúp agent của bạn dùng đúng các decorator của kiểm thử Ginkgo, như Serial, Ordered, Label, Focus và timeout, bằng cách giải thích mỗi decorator làm gì.
filtering
9.1kGiúp agent của bạn chỉ chạy một số bài kiểm thử Ginkgo, dùng pending, skip, focus, label, ràng buộc phiên bản và bộ lọc file theo đúng thứ tự ưu tiên.
ordering-and-flakes
9.1kGiúp agent của bạn kiểm soát thứ tự chạy kiểm thử Go và xử lý bài không ổn định, bằng Serial, Ordered và tùy chọn thử lại của Ginkgo.
Skill tương tự
test-driven-development
311kDạy agent của bạn viết kiểm thử thất bại trước, xem nó thất bại, rồi viết đoạn mã ngắn nhất để vượt qua trước khi làm bất kỳ tính năng hay bản sửa nào.
verification-before-completion
311kDạy agent của bạn chạy kiểm tra thực tế và đọc kết quả đầu ra trước khi khẳng định một việc, bản sửa hoặc bản build đã hoàn thành hay vượt qua.
migrate-to-shoehorn
310kThay các ép kiểu rủi ro trong tệp kiểm thử bằng thư viện shoehorn, để các bài kiểm thử dùng dữ liệu một phần vẫn qua được kiểm tra kiểu.