需要帮助解决上述 http://localhost:8081/states 的“无法获取 /states”问题。我已经浏览了 https://groups.google.com/forum/#!topic/pact-support/zGj8o6snf5c,这很有帮助,但没有找到答案。
GitHub 存储库 URL: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.
- 运行消费者和提供者 api
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 步的另一个问题是,当我单击输出中的链接时,它不会要求输入用户名和密码。
谢谢,
萨克希