Closed rgm closed 8 years ago
Hm, it should. The JS DSL should send through that information.
There should be a "write" call at the end of the suite (or somewhere) that causes the pact to be written. The "write on shutdown" was just a nice to have feature.
Sorry, I must not be understanding something right... it looked to me like run
would do this on cleanup by calling into verifyAndWrite
:
Yes, there is an explicit call from the JS code to write the pact, that's why the hook on shutdown isn't needed by the JS DSL. This line sends through the consumer and provider, that's why they aren't needed as arguments when starting the mock service: https://github.com/DiUS/pact-consumer-js-dsl/blob/f40d40b9433f1d65a13d8b5f956669e23ac268c4/src/mockService.js#L60
OK, thanks for your help. I added a Mocha hook
after(() => {
mockProvider.verifyAndWrite((err) => {
if (err) {
console.warn('Pact wasn\'t able to verify the interactions: \n' + err);
} else {
console.log('Pact verified and written.');
}
});
});
which seems to work so I don't need to give those flags. I'm adding a link to the relevant spot in the node example, just in case anyone else happens along this PR, and closing without merge.
Without all three of the
--consumer
,--producer
, and--pact-dir
flags, it appears that the mock service won't actually write a pact file on shutdown.I spelunked the source of
pact-mock-provider
a while scratching my head on why I wasn't getting anything written.