dimanche 8 novembre 2020

How to create integration tests medium sized, 3rd party API heavy nodejs applications?

I own a medium-sized nodejs application (https://github.com/pgonzaleznetwork/sfdc-happy-soup) that heavily relies on 3rd party APIs.

In a nutshell, what the app does is to call different Salesforce (low-code platform) APIs, both REST and SOAP, based on the input parameters AND based on the responses of some of the previous calls. This means that the execution path and the number of API calls for one request can be completely different from another request. Based on some input parameters the app could make more than 300 API calls in one request (via async processing of jobs).

I'm having a hard time figuring out how to create tests (mocha, jest, etc) for this app given the complexity of the API calls and their conditional logic.

Most of the examples online are about simple endpoints with a generic or predictable response and that can be tested with something like

assert(response)ToBe(200)

But my application has just too many different APIs, with a wide range of responses.

I could mock all these endpoints separately via unit tests, but frankly, that seems like way too much work and it would not give me end-to-end integration tests.

I could also mock the entire response of a complete job, and just create tests to assert that the code that processes that response works correctly, however, I'm more interested in testing the data transformation code that aggregates the results from all these API calls.

Has anyone been successful in created automated integration tests for apps that heavily relay and transform 3rd party data? If so, can you provide lessons learned, patterns, etc?

Aucun commentaire:

Enregistrer un commentaire