https://pact.io logo
#pact-js
Title
# pact-js
m

Matt (pactflow.io / pact-js / pact-go)

03/11/2022, 6:25 AM
Are you running your tests against a live provider?
h

Harry

03/11/2022, 6:25 AM
eventually they would be
m

Matt (pactflow.io / pact-js / pact-go)

03/11/2022, 6:25 AM
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

Harry

03/11/2022, 6:26 AM
like a virtualization server?
m

Matt (pactflow.io / pact-js / pact-go)

03/11/2022, 6:26 AM
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

Harry

03/11/2022, 6:27 AM
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

Matt (pactflow.io / pact-js / pact-go)

03/11/2022, 6:53 AM
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

Harry

03/11/2022, 10:57 AM
This sounds right, thanks for clarifying Matt.
👍 1
3 Views