test: add assertions for json response body

GitOrigin-RevId: b9ff0ad8e58bf96953980bb8aeb55aeee8138c04
This commit is contained in:
Pierre Caillaud 2025-11-21 11:11:37 +01:00 committed by ory-bot
parent 286f885e20
commit 0f5085c67a
2 changed files with 6 additions and 0 deletions

View File

@ -178,6 +178,9 @@ func InitializeLoginFlowViaBrowser(t *testing.T, client *http.Client, ts *httpte
res, err := client.Do(req.WithContext(o.Context()))
require.NoError(t, err)
body := x.MustReadAll(res.Body)
if isSPA {
require.True(t, gjson.ValidBytes(body), "body is not valid JSON: %s", string(body))
}
require.NoError(t, res.Body.Close())
require.Equal(t, 200, res.StatusCode, "%s", body)
if expectInitError {

View File

@ -53,6 +53,9 @@ func InitializeRegistrationFlowViaBrowser(t *testing.T, client *http.Client, ts
res, err := client.Do(req)
require.NoError(t, err)
body := x.MustReadAll(res.Body)
if isSPA {
require.True(t, gjson.ValidBytes(body), "body is not valid JSON: %s", string(body))
}
require.NoError(t, res.Body.Close())
if expectInitError {
require.Equal(t, 200, res.StatusCode)