New to Pact and perhaps I'm being obtuse, but I'm ...
# documentation
d
New to Pact and perhaps I'm being obtuse, but I'm finding the 5 minute getting started to be hard to follow, particularly the first parts on how to run stuff. The first part states, "Simply hit the green ▶️ button, and the output will be displayed in the terminal below. Give it a shot now". When I click the green ▶️ button, a new browser tab is opened at https://replit.com/@mefellows/Getting-Started-Intro#index.js. That is, no output was displayed in the terminal below. Then under "Ways to run" section, it says, "When you've picked an option, click the corresponding button". The first 2 options are about cloning a copy of the sample repo, but then what? Do I have to build anything? Do I just run
npm run test:consumer
? I didn't try the 3rd option as I didn't want to sign up for another service just yet. The 4th option is to just run in a browser, which opens a new tab with https://replit.com/@pact/pact-5-minute-getting-started-guide?outputonly=1&lite=true#README.md, but, again, then what? It looks like the same readme, but displayed on replit.com. The only apparent action that seems available is the green ▶️ button at the top. Clicking this open another new tab at https://replit.com/@pact/pact-5-minute-getting-started-guide#README.md with no apparent actions available. What am supposed to do here? I feel like I'm missing something. What am I supposed to see when I "run" things?
And, perhaps a minor point, but the use of the term "repl" would seem to warrant some explanation. I suppose programmers might be expected to know or quickly look it up, but having been in the industry 20+ years, in my circles at least, terms like command line or terminal are much more common. Seems like repl is uncommon enough and programmers come from so many varied backgrounds that it warrants some further clarity.
Btw, after cloning my fork and running npm install (if I'm a Java or C++ or Ruby developer, how would I know to do this?), I was then able to run
npm run test:consumer
and a json pact file was created. The pact file looks pretty simple and looks correct, but how do I know if it is?
I then moved on to the provider section, where it says, "You can see the published pact here." Clicking here opens a blank page (I can see that an API call is made to https://test.pactflow.io/pacts/provider/GettingStartedOrderApi/consumer/GettingStartedOrderWeb/latest which returns a 404). And, then it says, "For this purpose, we are going to use a hosted Pact Broker from pactflow.io" - do I need to set this up and then configure the sample project to point to the newly setup broker?
It looks like the project is configured to use a hosted broker with the canned username and pw so I tried running
npm run pact:publish
. It says it succeeded, but does also report
No value provided for option '--broker-base-url'
. Is this a problem or just informational?
Appears it was just informational since I was able to run
npm run test:provider
and it reported the test passed
Would seem helpful to explain how this example pact contract was used to verify the provider's actual response, particularly the body part. If such details are covered later, would be nice to have reference to more info on matching rules.
While I was able to get thru it, this 5 minute guide took me 2 hours. Seems like there's a lot of ambiguity and, IMHO, un-realistic assumptions in this guide. I'm pretty keen on the idea of contract testing so will keep at it, but in the spirit of constructive feedback, this didn't feel like a friendly intro.
m
Hi Demian, apologies for the confusion here. We discussed this in one of our maintainer catch ups recently. The tool repl.it has evolved quite a lot from when we first had this guide. Initially, you could just click “play” in each section and it genuinely only took a few minutes. repl.it has made it much harder to do that now, and I agree it’s VERY confusing.
The plan is to update this page to remove the repl.it stuff and put in code samples initially. It seems the dream of being able to run the examples in the browser is dying, so we’ll need to find a better way.
d
Hi Matt, thanks for the update! Glad to hear it's a recognized issue. Apparently, there wasn't a pact contract with repl.it 😉. As I mentioned, I'm still wanting to continue my learning. Are there other intros you'd recommend that perhaps don't have such issues? I see https://docs.pact.io/consumer and https://docs.pact.io/university. (for background, I'm an SDET working on a web app (react FE + Express/MySQL BE), and have been mainly doing Cypress automation). Thx!
(planning to order Contract Testing in Action soon)
m
The tutorials here are pretty good: https://docs.pactflow.io/docs/tutorials/ There are some in-browser ones (killercoda) and then there are actual lab workshops 👇 (howtolearn)
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
d
Thanks!