GM guys, is there a project structure standard / t...
# general
m
GM guys, is there a project structure standard / template we should follow for contract testing? a git example would be great 🙂 Thanks
👋 1
t
There are git examples in each pact-supporting language’s repository
which language are you using?
Also, generally, there’s no need to do anything special for Pact, structurally
It’s good to clear out the contract file directory before the test run
m
js, I was checking one example from the Test Automation University repo
there are many examples here
m
thanks @Timothy Jones, I’ll take a look
t
Pactflow also have some examples I believe, if you look on their github and filter by
example
, you’ll find many
m
thanks, I was using this one as a guide but I’ll take a look at the other examples https://github.com/rafaelaazevedo/tau-pact-nodejs-course
t
Cool. That’s an outdated version, but the concepts haven’t changed much
the latest version supports much better provider state setup
💯 1
m
good to know, Thanks @Timothy Jones
y
We have a range of examples here https://docs.pact.io/implementation_guides/workshops#examples As stated by Tim, the repo is using a 9.x version of pact and hasn't had any of the dependencies touched in a while, but there isn't much code so shouldn't be hard to update. I would note that it is publishing with
tags
where we prefer publishing with
branches
and deploying to
environments
- Tags previously were used for both, but now we have first class concepts. https://github.com/rafaelaazevedo/tau-pact-nodejs-course/blob/233d856433ff75bea904d1ceb43f747f53e51b4e/__tests__/helpers/publish.js#L9 We would also recommend use of the Pact CLI tools rather than the pact's JS api wrapper for the standalone client.
Tim's real point, it is always best to look at the projects source code and supporting site for examples, although I do note we do reference that site in our courses section, so it would be both apt and correct for the author to update and for us to help nudge them to do so.
Whilst external examples are brilliant and we love community users sharing them, I would be mindful of the date stamps of commits and the package versions, comparing them against the latest released versions. Even some of our own aren't always up to date, it is a large estate to manage. We would love support in helping update any, so I am sure a pull request against that course, with an update to the latest version of pact, axios, jest and the like wouldn't go amiss 👍
note if you have an existing project, and you are introducing contract testing, I wouldn't worry too much about following other example structures personally and just look to get a test working, within the unit testing framework that exists, where one is mocking out a provider.