需要帮助解决上述问题'无法获得/陈述'对于http:/ localhost:8081 / states。我已经完成了https://groups.google.com/forum/#!topic/pact-support/zGj8o6snf5c,它非常有帮助,但找不到答案。
GitHub存储库网址:https://github.com/pactfoundation/pactjs/tree/master/examples/e2e
我在我的机器OS X EI Captain [10.11]上设置了Pact-js e2e示例。
./node_modules/.bin/mocha test/consumer.spec.js
获得了成功的输出。
Pact
when a call to list all animals from the Animal Service is made
and there are animals in the database
✓ returns a list of animals
when a call to the Animal Service is made to retreive a single animal by ID
and there is an animal in the DB with ID 1
✓ returns the animal
and there no animals in the database
✓ returns a 404
when interacting with Animal Service
✓ should validate the interactions and create a contract

node test/publish.js
。获得了成功的输出。
Pact contract publishing complete!
Head over to https://test.pact.dius.com.au/ and login with
=> Username: dXfltyFMgNOFZAxr8io9wJ37iUpY42M
=> Password: O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1
to see your published contracts.

npm run api
。获得了成功的输出
Animal Profile Service listening on http://localhost:8081
Animal Matching Service listening on http://localhots:8080

./node_modules/.bin/mocha test/provider.spec.js
。此处出现错误
1) Uncaught error outside test suite
Pact Verification
Pact Verification Failed: Error: /Users/sakshi.rawal/work/pact-js/node_modules/@pact-foundation/pact-provider-verifier-darwin/lib/vendor/ruby/2.1.0/gems/json-1.8.3/lib/json/common.rb:155:in `parse': 757: unexpected token at 'Cannot GET /states (Faraday::ParsingError)
'

请帮我解决第4步的错误。 第3步的另一个问题是,当我点击输出中的链接时,它不会要求输入用户名和密码。
谢谢,
Sakshi
答案 0 :(得分:0)
上面列出的步骤3不是必需的,它只是测试和使用正在运行的API。
我怀疑第4步无法使用额外的端点运行提供程序,因为它已在步骤3中的同一端口上运行,因此失败。这意味着它无法在验证过程中找到端点/状态。
关闭所有进程,然后运行步骤4,应添加此端点,并且测试应该通过。
答案 1 :(得分:0)
您可以仔细检查是否已将最新代码拉下来?看起来像一个传递的依赖性转移,它不像现有的内容类型。我前几天打了补丁。