Are you running your tests against a live provider...
# pact-js
m
Are you running your tests against a live provider?
h
eventually they would be
m
oh, don’t do that. That’s not ideal
You want to be able to run the provider tests against a locally spun up version of the provider that can control its own data
h
like a virtualization server?
m
no, like in a dev environment
e.g.
npm start
with dependencies mocked
1. Start dev server 2. Run pact tests 3. shutdown dev server 4. [if on CI] publish verification results 5. [if on CI] run can-i-deploy 6. [if on CI and 5 passes] deploy
general workflow for a pact project
h
okay, but is there any way to achieve the uniqueness in case of email-ids getting generated everytime we run the consumer?
any randomized function or something like that?
m
Why is it a problem though? If you run it in a unit-test like context, the data is clean so there shouldn’t be conflicts
also, there are hooks (see the docs) that can fire pre/post test you can use to clear out any state in the database (if necessary) to achieve the same thing
If I said you needed to randomise an email address in your unit test email validation procedure because the email address already existed, you would likely tell me that something is wrong with my unit test. That’s essentially the mindset to bring to this problem
h
This sounds right, thanks for clarifying Matt.
👍 1