Tam Norris
05/22/2023, 3:25 PMreturn mockProvider.executeTest(async (mockserver) => {
// Act
const metersResponse = await callMeters(mockserver.url,'sgegegeg','2100040885876');
console.log('Type of meters resposne ' + typeof(metersResponse))
console.log('metersResponse is ' + JSON.stringify(metersResponse));
// Assert - did we get the expected response
expect(metersResponse.meters.postcode).toEqual("SW11"); //expect(product).toStrictEqual(JSON.stringify(expectedProduct));
return;
});
This is saying that received is undefined. However when I print the response in the console log above I do get an actual response i.e. ...
[
{
"errors":[
],
"meters":[
{
"address":{
"address_line_1":null,
"address_line_2":"SELECT",
"address_line_3":"TW23",
"address_line_4":null,
"address_line_5":"ST DAVIDS ONE",
"address_line_6":null,
"address_line_7":"ST DAVIDS CENTRE",
"address_line_8":"CARDIFF",
"address_line_9":"SOUTH GLAMORGAN",
"postcode":"CF10"
}
It doesn't work if I have metersResponse,meters[0].postcode either. Can anyone tell me what I am doing wrong? Also is the whole response being put in square brackets just the result of the stringify function?