Skip to content

Add CaptureSpecState helper method - #1694

Closed
jghiloni wants to merge 1 commit into
onsi:masterfrom
jghiloni:feat/add-capture-spec-state
Closed

jghiloni wants to merge 1 commit into
onsi:masterfrom
jghiloni:feat/add-capture-spec-state

Conversation

@jghiloni

Copy link
Copy Markdown

This method is useful for testing funcs that wrap run phase filters like Skip, Fail, or AbortNow.

This PR includes the code, the necessary updates to make tests pass, and doc updates.

If accepted, this PR would resolve #1693.

I have a working example of using this helper here. You can clone the repo and update the go.mod replace directive to test

This method is useful for testing funcs that wrap run phase filters like
Skip, Fail, or AbortNow.

This PR includes the code, the necessary updates to make tests pass, and
doc updates

Signed-off-by: Josh Ghiloni <github@joshghiloni.me>
@onsi

onsi commented Dec 1, 2026

Copy link
Copy Markdown
Owner

Thanks for this, @jghiloni.

I think the defer-based shape in the PR is a bit tricky as it puts some of the panic/recovery ceremony on the user and risks obscuring real failures.

I think a closure-based version is a bit easier to use and mirrors how Gomega intercepts failures so I’m implementing that if that’s ok with you:

state, failure := InterceptSpecState(func() {
    SkipIfEnvSet("CI")
})
Expect(state).To(Equal(types.SpecStateSkipped))

@jghiloni

jghiloni commented Dec 1, 2026

Copy link
Copy Markdown
Author

Oh yeah, that's way more elegant!

@onsi

onsi commented Dec 1, 2026

Copy link
Copy Markdown
Owner

Landed as InterceptSpecState in 908ec7e (docs: "Testing helpers that call Skip or Fail"); it'll be in the next release. Thanks again @jghiloni!

@onsi onsi closed this Dec 1, 2026
@jghiloni
jghiloni deleted the feat/add-capture-spec-state branch December 1, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add helper method to test run phase filters like skip

2 participants