Hello, I've tried to use BeforeEach method and I s...
# pact-go
k
Hello, I've tried to use BeforeEach method and I see problems with multiple state setup. The problem is that BeforeEach runs before every state within one interaction, which basically doesn't make sense as it reset the setup from the previous state. My code:
Copy code
interaction('Getting application', ({ provider, execute }) => {
    beforeEach(() => {
      provider
        .given("Application exists", appParams)
        .given("Application has components", compParams)
        .uponReceiving('Get app with its components.')
        .withRequest(contract.request)
        .willRespondWith(contract.response);
    });
    ...
   }
The log is like this:
Copy code
2023-10-24T08:30:08.922544Z  INFO ThreadId(13) pact_verifier: Running setup provider state change handler 'Application exists' for 'Get app with its components.'
beforeeach - clean up
2023/10/24 10:30:08 [INFO] executing state handler middleware
application created
2023-10-24T08:30:09.190301Z  INFO ThreadId(13) pact_verifier: Running setup provider state change handler 'Application has components' for 'Get app with its components.'
beforeeach - clean up
application removed
2023/10/24 10:30:09 [INFO] executing state handler middleware
"create component error": "unable to get the Application"
In the doc I found that multiple state setup is upported in V3 scheme, which is what we're using. Am I doing anything wrong?
👍 1