axios-mock-adapter icon indicating copy to clipboard operation
axios-mock-adapter copied to clipboard

config.data is a string

Open DaveStein opened this issue 7 years ago • 0 comments

When I am passing an object as data, I still need to do JSON.parse as below, if I want to do something like expect(data.x).toEqual(1);. I am passing headers of application/json so I'd imagine mock adapter can read that and know to return a parsed string vs not.

mock.onPost('https://site.com/v1/jobs')
  .reply(({data}) => {
    data = JSON.parse(data);
    return [200, jobResponse];
  });

DaveStein avatar May 30 '18 17:05 DaveStein