Hi,
I have a sample project that I recently upgraded to 2.2.0.
https://github.com/shavo007/pact-demo/tree/dev-lees-js-consumer-upgrade/jsConsumer
If i run gulp pact the error in the logs is:
[10:45:45] Finished 'createPacts' after 8.63 s
[10:45:45] Starting 'publishPacts'...
[2017-03-13T23:45:45.139Z] ERROR: [email protected]/90149
Could not retrieve all Pact contracts:
- Invalid Pact contract "pacts/js_consumer-provider1.json":
Error: Cannot find module 'pacts/js_consumer-provider1.json'
--
Error: Could not retrieve all Pact contracts:
- Invalid Pact contract "pacts/js_consumer-provider1.json":
Error: Cannot find module 'pacts/js_consumer-provider1.json'
at /Users/shanelee/java-projects/pact-demo/jsConsumer/node_modules/@pact-foundation/pact-node/src/publisher.js:63:16
I see the pact exists at jsConsumer/pacts/js_consumer-provider1.json
The opts defined in gulpfile are:
var opts = {
pactUrls: ['pacts'], // Array of local Pact files or directories containing them. Required.
pactBroker: 'http://localhost',
consumerVersion: '1.0' // URL to fetch the provider states for the given provider API. Optional.
};
ENV:
Node: v7.5.0
"pact": "^2.2.0"
Any clue?
Thanks.
Shane.
Ah, the pactUrls requires the path to be absolute in the latest version. I'll update the docs accordingly, but for now patching your publish task like this should fix your problem:
var path = require('path');
pactUrls: [path.resolve(process.cwd(), 'pacts')],
that worked perfectly. thanks.
out of interest, @mefellows why is it absolute now instead of relative?
i will leave this issue opened for now until the doc has been updated.
Thanks @shavo007, I'll follow up on that, short answer is I'm not sure.
No worries mate
Looks like it was an unintended consequence (albeit if you provided it with a directory it needed to be absolute anyway), I'll raise an enhancement request. It seems fairly low priority though.
馃憤
Can there not just be some sensible defaults around this kind of stuff? Like make pactUrls optional and just default it to /pacts under your project root?
Probably, we'll happily accept a PR if you're willing :)
Thanks for the opportunity! Very keen to. Hopefully soon!