0

I am new to Cypress and trying to find the best/good practices for doing api test. My goal is to create an automation API test using cypress but can't find structure/guidelines to follow.
Can anyone share a documentation or experiences on how the folder structure/setups/test data readable and manageable?

1

2 Answers 2

2

If you want to test components (some consider framework components as units) at the framework level such as React or Angular you can use https://docs.cypress.io/guides/component-testing/overview

For network specific testing (network = api's) you can follow the guidelines for networks at https://docs.cypress.io/guides/guides/network-requests however this is not designed specifically for testing API's. It's more about how to deal with API's when browser testing and the browser is making the API calls. You can put together a custom app that uses a browser just to reach endpoints but you are moving away from the tools intended use and that doesn't usually end well in terms of a sustainable solution.

Cypress is a good tool for browser testing, possibly the best current imho. For API testing I recommend you use Postman (with Newman for job running) as that is the best tool in the API testing space. As you can use Newman to create automated suites to run in CI this is a good option. You can pair it with mocked unit tests for great test coverage

The arrangement of data and files can be seen from their documentation and examples.

1

Yes you can however:

  • Cypress run everything within a browser i.e. extra usage of CPU/Memory resources which is not needed for API testing, unless your test scenarios needs more than pure API call-response verifications.

  • On the other hand, Cypress allows you to quickly inspect and debug the data coming back from your APIs against the actual data returned in the original requests.

AFAIK, the latest version of Free Postman has number of calls limitation. see here.

Have a look at Playwright as an alternative.

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .