Hi, I am looking for JS consumer test examples tha...
# pact-js
v
Hi, I am looking for JS consumer test examples that use the gRPC plugin. I only found this one https://github.com/YOU54F/pluginopedia/blob/main/example-project-js-grpc-plugin/test/matt.consumer.spec.ts. But that was last updated 8 months ago so I am not sure if that's still up to date. Are there more? Our project is a React frontend that connects to a golang backend using gRPC-Web with an Envoy proxy. The Envoy proxy is needed to convert HTTP/1.1 requests from web browsers to HTTP/2 used by gRPC. Can we use Pact for this scenario? I assume Yes since the JS consumer test will be making the gRPC requests and not a web browser.
👋 1
m
This is an example using a plugin, but it doesn’t use gRPC
We can’t have examples in every language for every plugin, but hopefully this helps: https://github.com/pact-foundation/pact-js/blob/master/examples/v4/plugins/test/matt.consumer.spec.ts
Hopefully that helps get you on track
y
the package versions are out of date in my example but it works, and others have used it as a basis for getting their own grpc tests in js running
🙌 1
8 months isn’t terribly old if i’m honest
☝️ 1
it’s difficult maintaining multiple e2e examples in our main client lib repos, especially with the multitude of test frameworks, protocols etc. should be able to use with envoy fine, i played with it back at my original adventure with grpc
👍 1
i’ve just had a look at the example again, if you update pact-js to 12.0.0 it’ll come with the native libraries pre bundled and you can remove the pact-core import the loop back interface for the host name might cause you bother, but other than that we’ve had a few reports of success from people seeing that example note to @Matt (pactflow.io / pact-js / pact-go) and me let’s get a recipe page up for grpc on the docs website and we can provide pointers to the tests in the various impls. i’ll get an area calculator example for pact js at some point, that is the canonical example in the pact plugins repo i’ve got one in deno pact which was a port a of the pact js interface https://github.com/YOU54F/deno-pact/blob/main/src/usage/areaCalculatorClientTest.ts so the lift shouldn’t be too hard. we would gladly appreciate a js example here 👇 https://github.com/pact-foundation/pact-plugins/tree/main/examples/gRPC/area_calculator it keeps them all in the same home and makes them easier to test cross language
thankyou 1
v
Thank you so much @Matt (pactflow.io / pact-js / pact-go) and @Yousaf Nabi (pactflow.io)! Really appreciate your help. Yeah I think my teammate was having trouble with the host name. It would be awesome to have a recipe page for gRPC and find all the examples in one place. For now, we have switched to using pact golang for consumer and provider tests. But we will go back to JS soon.
👍 1
m
You mentioned you are moving between languages - how are you writing your tests? Usually, the tests would be unit tests - so switching languages makes that a rather difficult thing to do and worries me. Can you please elaborate?