F
F
frontendo2017-09-29 19:23:05
WooCommerce
frontendo, 2017-09-29 19:23:05

What is the best library to test JSON responses from the server API?

I would like to write system tests for the service API. I use mocha + should + supertest for testing.
But a record of the form

res.status.should.equal(422);
res.body.should.have.property('errors').which.is.a.Object();
res.body.errors.should.have.property('email');

I'm not very comfortable when there is a lot of information in the JSON response,
I would like something like this
assert(res.body, {
    errors : {
        email: string
    }
})

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
kafkiansky, 2019-06-19
@mad_maximus

First, read about psr , then get rid of global variables and read about dependency injection, classes (if they can be introduced into VP at all).

N
Negwereth, 2017-09-29
@Negwereth

Look towards JSON Schema

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question