我第一次使用 Pact.js 进行微服务测试。我尝试遵循以下示例:
https://github.com/pact-foundation/pact-js/tree/master/examples/e2e
https://github.com/pact-foundation/pact-js/tree/master/examples/mocha
在示例 3 中;我导航到测试文件夹并运行mocha index.spec.js
但它会引发以下错误:
[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)
它按预期创建log
andpact
文件夹,但它既不在pact.json
pact 文件夹中创建文件,也不在 log 文件夹中记录文件。
更让我感到困惑的是,我在示例 1 和示例 2 中得到了完全相同的错误。这告诉我我有一个问题,但我不知道它是什么。有人可以帮我调试问题吗?