Hi! may I ask how to solve the error with ECONNREF...
# pact-js
s
Hi! may I ask how to solve the error with ECONNREFUSED with providerBaseUrl ? I used axios-mock-adapter but it still failed
m
What are you mocking? The provider? If so, you don't mock the provider in the provider test - we need to test the provider!
I'd suggest doing one of the tutorials or workshops below (howtolearn) to understand how it all works
s
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops
s
I just followed the example in github, and the pact verifier will complain if I do not provide the providerBaseUrl.
Copy code
1) receive get organisation parent id request
       return organisation parent id:
     Error: 'providerBaseUrl' is mandatory if no 'messageProviders' or 'transports' given
      at new ConfigurationError (node_modules/@pact-foundation/pact/src/errors/configurationError.js:21:42)
      at new Verifier (node_modules/@pact-foundation/src/dsl/verifier/verifier.ts:71:13)
      at /Users/shensiyuan/Desktop/organisations/backend/src/get-parent/get-parent-contract.test.ts:77:18
      at Generator.next (<anonymous>)
      at /Users/shensiyuan/Desktop/organisations/backend/src/get-parent/get-parent-contract.test.ts:8:71
      at new Promise (<anonymous>)
      at __awaiter (src/get-parent/get-parent-contract.test.ts:4:12)
      at Context.<anonymous> (src/get-parent/get-parent-contract.test.ts:76:50)
      at processImmediate (node:internal/timers:466:21)
My lambda provider is triggered by api gateway, so I’m trying to create a mock server to call my lambda function
Maybe I need to search about providerBaseUrl in verifier again, because this one is really confuse me hahaha.
t
Are you verifying an http endpoint?
if yes, and that endpoint is connected by API gateway, then you need to stand it up somehow. With API Gateway I think you can use localstack. Or, possibly you could deploy to a dev environment
you will need to be able to stand up your service to the point that you can send http requests to it
and once you have done that, you give the URL of the service to
providerBaseUrl
s
So may I ask the purpose of
providerBaseUrl
?
t
That’s how you tell pact where your service is running
so it can run the verification
As Matt said, the tutorials will walk you through all these concepts
s
Got it! thanks!