Automation Test

Ginkgo detected a panic while constructing the test tree

How to fix this

Donald Le
2 min readJun 7, 2022
Ginkgo detected a panic while constructing the test tree.
You may be trying to make an assertion in the body of a container node
(i.e. Describe, Context, or When).

Please ensure all assertions are inside leaf nodes such as BeforeEach,
It, etc.

Here's the content of the panic that was caught:
Your Test Panicked
When you, or your assertion library, calls Ginkgo's Fail(),
Ginkgo panics to prevent subsequent assertions from running.

Normally Ginkgo rescues this panic so you shouldn't see it.

However, if you make an assertion in a goroutine, Ginkgo can't capture the
To circumvent this, you should call

defer GinkgoRecover()

at the top of the goroutine that caused this panic.

Alternatively, you may have made an assertion outside of a Ginkgo
leaf node (e.g. in a container node or some out-of-band function) - please
move your assertion to
an appropriate Ginkgo node (e.g. a BeforeSuite, BeforeEach, It, etc...).

Learn more at:

This happens because I have an assertion of Ginkgo outside BeforeSuite, BeforeEach , or It..

So to fix this, I just removed the assertion from the outside function.

func SignIn(account string, password string, ctx context.Context) string {client := resty.New()requestBody := fmt.Sprintf(`{"email": "%s","password": "%s"}`, core.GetKey(account, ctx), core.GetKey(password, ctx))resp, _ := client.R().SetHeader("Content-Type", "application/json").SetBody(requestBody).Post(core.GetCfg().Domain + core.GetCfg().Service.ABC.Url + "/user/signin")// Expect(resp.StatusCode()).To(Equal(http.StatusOK))myResponse := dto.UserSignInResp{}err := json.Unmarshal(resp.Body(), &myResponse)if err != nil {fmt.Println(err)}return myResponse.Data.JWTToken}

Happy testing guys~~



Donald Le

A passionate automation engineer who strongly believes in “A man can do anything he wants if he puts in the work”.