Skip to content
This repository has been archived by the owner on Feb 27, 2022. It is now read-only.

Response Assert Json Structure #31

Open
wardy484 opened this issue Dec 2, 2018 · 3 comments
Open

Response Assert Json Structure #31

wardy484 opened this issue Dec 2, 2018 · 3 comments

Comments

@wardy484
Copy link

wardy484 commented Dec 2, 2018

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

@RomainLanz
Copy link
Member

Hey @wardy484! 👋

This is indeed a very great feature to have.
I'll happily merge a PR that provide some JSON Schema validation 👍

@mfgabriel92
Copy link

Any updates?

@thetutlage
Copy link
Member

Will start working on it as part of AdonisJs v5 release

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants