Hello,
i am working with mocha testing, and using nock to mock a get request which returns data in form of an
array.
3rd Part Api returns data (in form of array):
[
{
"name": "Stamps.com",
"code": "stamps_com",
"accountNumber": "SS123",
"requiresFundedAccount": true,
"balance": 24.27,
"nickname": null,
"shippingProviderId": 12345,
"primary": true
}
]
So, to mock above data,
i am trying to do
let mockCarriers = [
{
"name": "Stamps.com",
"code": "stamps_com",
"accountNumber": "SS123",
"requiresFundedAccount": true,
"balance": 24.27,
"nickname": null,
"shippingProviderId": 12345,
"primary": true
},
]
nock(apiUrl).get('/carriers').reply(200, mockCarriers).persist();
But, instead of taking it as an array, it takes it as a string.
After researching, i found this : https://github.com/nock/nock#specifying-replies
that states the replies that can be set over reply method.
So, i am wondering, if this is possible to return array instead of object from the reply method ?
Open to suggestions.
Please suggest.
Thank you.
Hello,
i am working with mocha testing, and using nock to mock a get request which returns data in form of an
array.
3rd Part Api returns data (in form of array):
So, to mock above data,
i am trying to do
But, instead of taking it as an array, it takes it as a string.
After researching, i found this : https://github.com/nock/nock#specifying-replies
that states the replies that can be set over reply method.
So, i am wondering, if this is possible to return array instead of object from the reply method ?
Open to suggestions.
Please suggest.
Thank you.