2017-02-24 60 views
0

需要幫助解決上述問題'http/localhost:8081/states不能GET/states'。我已經通過https://groups.google.com/forum/#!topic/pact-support/zGj8o6snf5c,這是非常有幫助,但沒有找到答案。Pact-js e2e示例實現[問題:無法獲取/狀態] MAC操作系統

GitHub的庫網址:https://github.com/pactfoundation/pactjs/tree/master/examples/e2e

我已經設置了該條約,JS E2E例如我的機器OS X EI船長[10.11]上。

  1. 運行消費者測試./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 .GOT錯誤這裏
  • 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

    更正上述步驟 – Sakshi

    回答

    0

    你可以仔細檢查你有最新的代碼拉下來?看起來像一個傳遞依賴轉移,不喜歡現有的內容類型。我前幾天打了補丁。

    +0

    謝謝:)我做了git pull並且它工作的很好,只是關於/ states和/ setup的一件事,第3步當我點擊這些端點時,它說不能獲得/ states,同樣的錯誤是/ suggestions/1,/ setup。僅在運行提供程序規範時生成? – Sakshi

    +0

    正確。他們將爲相應的客戶端測試設置數據夾具,這些客戶端測試期望數據存在或不存在 –

    +0

    但是當配置文件api運行時,http:// localhost:8081/states給出不能GET /states.It應該給出狀態 ? – Sakshi

    0

    步驟3不是必需的,它是簡單地測試和使用運行的API。

    我懷疑步驟4無法運行具有額外端點的提供程序,因爲它已經在步驟3中的同一端口上運行,因此失敗。這意味着在驗證過程中無法找到端點/狀態。

    關閉所有進程,然後運行第4步,應添加此端點,並通過測試。

    +0

    對不起,延遲了回覆。感謝@Matthew Fellows Step 4在我關閉了第3步中的過程後正常工作。但現在的錯誤是: '條約驗證失敗:錯誤:/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:'TypeError:invalid media type'的意外標記
       位於Object.parse(/Users/sakshi.rawal/ work/pact-js/examples/e2e/node_modules/content-type/index.js:130:11)
    &nbs「.' – Sakshi

    +0

    它現在可以工作嗎?請問您可以標記爲已回答嗎? –