Hi! Are there some kinds of before and after for s...
# pactflow
n
Hi! Are there some kinds of before and after for states on the provider side? How can we clean up the database in between different states?
m
this is probably a language specific answer. But the simplest, is to clean the database as needed in the provider state callback itself
some have before/after hooks (like JS, Go)
n
Oh yes so there is a provider state callback? Sorry I must have missed this, do you mind sending the docs or PoC that has this step?
m
What language Noor?
Oh yes so there is a provider state callback? Sorry I must have missed this, do you mind sending the docs or PoC that has this step?
the language I used there might have been misleading. I’m simply suggesting that the provider state handler be responsible for setting up its state, and not worrying about the state from others.
👍 1
n
I'm using javascript specifically the nest js pact package
Oh so I looked at the example you gave and I already have state handles in my code to populate the database, so are you suggesting that in each state handler, before I populate the test db with the specific data I can clear out the database first then populate what I need, correct?
m
yep, pretty much
There should be before/after hooks though as Pact JS has that. I’m not really across the NestJS package, but presumably you should be able to access them, if not, it should be easy enough to expose through the API I imagine
🙌 1