When running the test suite, we make a call to the TruckersMP API and use the response to assert our logic. However, this is definitely not how things should be done. This could cause issues if the API is offline for example.
Instead, we should update the test suite to instead mock the response (this could be done by loading an example response/schema from a JSON file) and then test our logic.
This will need a bit of investigation into how we can mock the response as some tests call multiple endpoints.
One thing to note with this is that if the schema was to change i.e. a value changes from a string to a boolean we wouldn't catch that due to the response being mocked. However, it is definitely better to mock the response rather than calling the API.
When running the test suite, we make a call to the TruckersMP API and use the response to assert our logic. However, this is definitely not how things should be done. This could cause issues if the API is offline for example.
Instead, we should update the test suite to instead mock the response (this could be done by loading an example response/schema from a JSON file) and then test our logic.
This will need a bit of investigation into how we can mock the response as some tests call multiple endpoints.
One thing to note with this is that if the schema was to change i.e. a value changes from a
string
to aboolean
we wouldn't catch that due to the response being mocked. However, it is definitely better to mock the response rather than calling the API.