jeudi 31 mai 2018

keep mocked apis in sync with documentation

I have a Vue js application with some mocked api for testing purposes. The library I use to handle http request is Axios and the library to mock everything is Axios-mock-adapter:

mock.onGet(/.+\/api\/annotation/).reply(() =>
    [200, ResponseObject.getTopics],
);

In another file that I import I have all the response object:

const getTopics = {
  topics: [
    {
      id: 'source',
      name: 'am',
    },
  ],
};

This approach works but is pretty limited because when some back-end guy updates the documentation I have to manually change the response object, otherwise my tests would still pass and they shouldn't.

There's a way to keep in sync the doc with my object file? The ideal set up would be that before starting the testing phase I download automatically a json containing all the response to the api based on the doc...

There's a way to achieve that?

Aucun commentaire:

Enregistrer un commentaire