I am using Pact.js first time for microservice testing. I tried to follow these following examples:
https://github.com/pact-foundation/pact-js/tree/master/examples/e2e
https://github.com/pact-foundation/pact-js/tree/master/examples/mocha
In example 3; I navigate into test folder and run mocha index.spec.js
But it throws the following error:
[2017-02-27T21:37:52.426Z] INFO: pact-node@4.8.0/38629 on Meliss-MacBook-Pro.local: Creating Pact with PID: 38630
1) "before all" hook
2) "after all" hook
0 passing (2s)
2 failing
1) The Dog API "before all" hook:
Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
2) The Dog API "after all" hook:
Error: connect ECONNREFUSED 127.0.0.1:8989
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1087:14)
It creates the log
and pact
folders as expected, but it neither creates a pact.json
file in the pact folder nor logs files in the log folder.
What confuses me more is I get the exact same error in examples 1 and 2. This tells me that I have an issue on my side but I don't know what it is. Can someone help me to debug the issue?
Can you please try the following?
logLevel: 'DEBUG'
in any pact({...})
declarationsAnd provide us a gist of the output.
It seems the Ruby mock server is not starting or is taking longer than 2 seconds, and the node process is timing out waiting for it to come up.
If that doesn't work, please try manually starting the mock service ./node_modules/bin/pact-mock-service --port 1234
and when it comes up, run the command netstat -an | grep LISTEN | grep 1234
so that we can see what network it is binding to.