I am trying to run tests against nestjs provider- ...
# pact-js
j
I am trying to run tests against nestjs provider- https://github.com/pact-foundation/pact-js/tree/master/examples/nestjs-provider, Contracts generated while adding the tests against nestjs consumer is there in broker. i have set up the provider using npm start and then tried to run npm test . i am trying to run tests against provider and validate the contract so that it succeeds. i have added broker url and token.
Copy code
You cannot provide both a username/password and a bearer token. If your Pact Broker uses a bearer token, please remove the username and password configuration.
m
the error message is likely telling you the truth 👉 “You cannot provide both a username/password and a bearer token. If your Pact Broker uses a bearer token, please remove the username and password configuration.”
j
okk, commented it out and it works
does the example provided updates the interactions in broker. My broker and provider side. Provider side we are running the tests .Or are they(Nestjs Consumer and Nest Provider) independent examples just for showcase
m
hmm something doesn’t look right there
the verification definitely didn’t do anything useful
the process exited before any tests were run
(to answer your question - yes, they are designed to work together)
j
it ran the test,looks like it just prints some data to console.Hope it works same way like https://github.com/pactflow/example-provider
m
no, something is not right there. It should print out what it tested. It looks like it didn’t find anything to test
OK so it’s “expected” but it’s not correct: https://github.com/pact-foundation/pact-js/runs/6257077748?check_suite_focus=true#step:4:1638
@Omer Morad FYI the example is not actually fetching the consumer pacts correctly. I’ll update now
🙏 1
j
Okk thanks
m
The main issue is that the consumer is publishing the branch information, but no tags. The verifier is using tags to find the pacts, so it doesn’t find any
changing to
providerVersionBranch
to match the consumer is one approach to fixing it. You could also look at how the example consumer/provider are configured
j
i didnt get you, i couldnt find the above branch, what changes i can make in consumer side ,so that it can publish tags as well
m
have a look at the options for publishing usins the
pact-broker publish
command that Pact JS installs
Currently, the consumer is already adding the correct branch information to the consumer contract, so you just need to fetch the same branch on the provider side. Alternatively, you can use tags.
see the CI/CD workshop in 👇 (howtolearn) for more on the optimal flow
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