Closed marcbachmann closed 3 months ago
Change the parameters of the methods to align it to the one of axios. The last parameter must be a config object with {params, headers} instead of just the headers. If you've always only used two parameters, you won't have to change anything.
{params, headers}
Methods with data param:
mock.onPost(url, data, headers)
mock.onPost(url, data, {params, headers})
mock.onPut(url, data, headers)
mock.onPatch(url, data, headers)
mock.onPatch(url, data, {params, headers})
mock.onAny(url, data, headers)
mock.onAny(url, {data, params, headers})
Methods without data param:
mock.onGet(url, {params}, headers)
mock.onGet(url, {params, headers})
mock.onDelete(url, {params}, headers)
mock.onDelete(url, {params, headers})
mock.onHead(url, {params}, headers)
mock.onHead(url, {params, headers})
mock.onOptions(url, {params}, headers)
mock.onOptions(url, {params, headers})
An error is reported if one accidentally passes the headers directly instead of `{headers: {}}.
e.g. Error: Invalid config property Header-test provided to onPatch. Config: {"Header-test":"test-header"}
Error: Invalid config property Header-test provided to onPatch. Config: {"Header-test":"test-header"}
Breaking Change 💥
Change the parameters of the methods to align it to the one of axios. The last parameter must be a config object with
{params, headers}
instead of just the headers. If you've always only used two parameters, you won't have to change anything.Methods with data param:
mock.onPost(url, data, headers)
>mock.onPost(url, data, {params, headers})
mock.onPut(url, data, headers)
>mock.onPost(url, data, {params, headers})
mock.onPatch(url, data, headers)
>mock.onPatch(url, data, {params, headers})
mock.onAny(url, data, headers)
>mock.onAny(url, {data, params, headers})
Methods without data param:
mock.onGet(url, {params}, headers)
>mock.onGet(url, {params, headers})
mock.onDelete(url, {params}, headers)
>mock.onDelete(url, {params, headers})
mock.onHead(url, {params}, headers)
>mock.onHead(url, {params, headers})
mock.onOptions(url, {params}, headers)
>mock.onOptions(url, {params, headers})
An error is reported if one accidentally passes the headers directly instead of `{headers: {}}.
e.g.
Error: Invalid config property Header-test provided to onPatch. Config: {"Header-test":"test-header"}