DEV Community

Discussion on: Why Data APIs are bad for UI Testing

Collapse
 
alanmbarr profile image
Alan Barr

With an API it depends on what we are trying to test and what risks are we trying to mitigate. APIs are great for mocking up complicated UI testing scenarios or triggering state in a specific way before testing something else. There could be benefits as well around API contract testing during development changes. If you provide the API there can be some sanity checking done but if you're implementing an external API what's the point of testing it? Trust must be extended at some point otherwise we make lots of work for ourselves. There is a good use case for API contract testing such as PACT since end-to-end tests for everything in a large enough environment are too time-consuming and expensive.

Collapse
 
jessekphillips profile image
Jesse Phillips • Edited

I wasn't writing about API testing. EDIT: let me rephrase that, I suggested API contract testing on third party API to mitigate risks if that is a high enough risk for you, but yes I do think trust is needed at some point.

When you say

if you're implementing an external API what's the point of testing it?

Do you mean behind a third party API consumer?

Contract testing is definitely the approach I lean on for automation.

Collapse
 
alanmbarr profile image
Alan Barr

Yeah was just referring to the original article writer and wondering what they're trying to convey to the audience.