Response Assert Json Structure
It would be great if there was a function on the like in Laravel that allows you to verify the structure of the JSON response rather than specific value as in all case you might not be interested what really in the data want to be sure that it is present.
e.g. response.assertJSONStructure([ 'bearer', 'token', 'refreshToken ]);
Why this feature is required (specific use-cases will be appreciated)?
It's very much a nice to have. However in my case I am testing a sort of register user endpoint and expect back the auth object. I would like to verify that the token is part of the response but I generally don't care what the actual value is.
Have you tried any other work arounds?
This seems to do the job however it's not particularly clear to read.
assert.containsAllKeys(response.body, ['token'])
Are you willing to work on it with little guidance?
yes
Hey @wardy484! 👋
This is indeed a very great feature to have. I'll happily merge a PR that provide some JSON Schema validation 👍
Any updates?
Will start working on it as part of AdonisJs v5 release