Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options to specify output #245

Open
rnphilp opened this issue Sep 13, 2021 · 1 comment
Open

Options to specify output #245

rnphilp opened this issue Sep 13, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@rnphilp
Copy link

rnphilp commented Sep 13, 2021

OpenAPI version
3

Is your feature request related to a problem? Please describe.
When using the toSatisfyApiSpec function, the output often overruns the history limit of the terminal. This is the case when the API route being tested returns an array of items (even if only one of the objects in the whole array is invalid), or when running a full test suite, where there are multiple errors returned. The output of the body response can be too large, making it difficult/impossible to navigate to the actual issues, when the key information is just the initial message at the top.

Describe the solution you'd like
An options object that passed into the function allowing you to suppress certain sections of the output. Something like:

toSatisfyApiSpec({ message: true, response: false, schema: false })

Everything can be true by default to avoid changing the current functionality.

Describe alternatives you've considered
Reducing the request body logs to remove the valid items in the array and only include the errors. So the output would be more like:

{
  my_response: [
    ...
    {
       foo: 'bar',
       error: 'in_just_this_object',
    }
    ...
  ]
}

Or just displaying a reduced snapshot of that section of the body, with say 5 lines above and below.

Additional context
No

Are you going to resolve the issue?
Not currently got the opportunity.

@rnphilp rnphilp added the enhancement New feature or request label Sep 13, 2021
@rwalle61
Copy link
Collaborator

rwalle61 commented Sep 20, 2021

Hi @rnphilp, thanks for raising this! Would you mind recreating this with our recreation template, so we can see exactly which output is too verbose?

For context, some of the error output comes from our validation dependency, but we are the ones deciding to output the whole response body, to aid debugging (but in this case it can be improved).

Just as a note - if our output overruns the history limit of the terminal because many tests are failing their toSatifyApiSpec() assertions, I'd suggest running and fixing those tests one by one.

Thanks for bringing this to our attention 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants