cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.04k stars 3.18k forks source link

Cypress GRPC plugin #19973

Closed mariuszadam closed 2 years ago

mariuszadam commented 2 years ago

What would you like?

Easy way to test GRPC backend calls. Currently there is no clear description how to use GRPC with cypress. There is an option to introduce REST gateway, but this is fallback to REST instead of using GRPC fully.

E.g. for REST cy.request({ method: 'GET', url: appUrl/status }).then((response) => { expect(response).body('state').to.equal("running") });

**what would be the equivalent for the GRPC service?**
url is appUrl
grpcMessage: "statusCheck"
proto file is: my.proto    

Why is this needed?

GRPC is 10x more efficient than using rest (speed and size of messages) according to the web tutorials. Highly likely that GRPC is going to replace REST for a the new applications.

Cypress is great, but it lacks examples and tutorials how to use it with GRPC if GRPC server has no rest-like endpoints like swagger (REST gateway).

Other

No response

mariuszadam commented 2 years ago

I was able to utilise grpcC node lib https://www.npmjs.com/package/grpcc

with cy.exec()

but still it's more like workaround not out of the box grpc support

flotwig commented 2 years ago

Hi @mariuszadam, what kind of GRPC testing are you doing? Are you sending GRPC requests from your plugin code and testing the outcome?

I think it's unlikely that we would add GRPC support to the core of Cypress since it falls out of scope of testing web applications, since web applications need a gateway to use HTTP/2 GRPC. I think creating a plugin for this would be a great idea.

mariuszadam commented 2 years ago

I'm testing a GRPC backend service. For some endpoint (features) it has REST gateway, but not for all features endpoints are exposed via swagger.

I found a way, at least for basic usage, described here. https://github.com/cypress-io/cypress/discussions/19653

Cypress is a great tool :) So I'm wondering if I can cover my cases in some better way than huge commands and parsing results' strings.

flotwig commented 2 years ago

Ah, okay, I see. You could abstract away a lot of that functionality in a custom cy. command: https://docs.cypress.io/api/cypress-api/custom-commands#Arguments

Otherwise, since this is not in the scope of Cypress to support out of the box, I'll close this issue. If you do end up making a plugin for this, you can submit it to the plugins directory: https://docs.cypress.io/plugins/directory

mariuszadam commented 2 years ago

@flotwig thank you so much for your time and responses :)