Hello quick question about `stateHandler` , we wil...
# pact-js
h
Hello quick question about
stateHandler
, we will use real provider side API to generate data, however, when stateHandler is failed, it does not execute the other tests, what is good practice workaround in here? for example, some verifier from provider side doesnt need stateHandler, if state handler somehow error/fail, shall we execute rest of them? any good tip for jest setup for provider? we use
jest-each
to loop all contract in provider side.
Copy code
each(needToBeVerified).it('should verify the expectations of %p Graphql', contractName => {
      return new Verifier(createOptions(`${contractName}-provider`)).verifyProvider().then(output => {
        if (output.includes('Diff')) {
          console.log(output)
          throw new Error(`${contractName} contract test error`)
        }
      })
t
I'm a bit confused here - what does the
createOptions
function do? If the state handler fails, Pact assumes that the test is a failure, because the state was not correctly setup.
it should execute the contracts where the failing state handler is not used successfully.
Also, I don't think this is a good check
if (output.includes('Diff')) {
- Diff happens to be in the output of a failed test, but it's not part of the contract
each(needToBeVerified).it(
<-- I'm not familiar with this construct - the one that is in the jest docs is
it.each(table)(name,fn,timeout?)
that might not be a problem (jest contains lots of things that aren't documented exactly)
h
createOptions
is just verifier config, such as
Copy code
{
    provider: providerName,
    providerBaseUrl: ,
    pactBrokerUrl:
}
Diff happens to be in the output of a failed test, but it’s not part of the contract
OK that is good to know thanks! I will add failure
and
each
is
jest-each
library https://www.npmjs.com/package/jest-each 🙂
it should execute the contracts where the failing state handler is not used successfully.
yeap that is what I expected lol, I will try different way! thanks a lot.