Sakshi
Sakshi

Reputation: 11

Pact-js e2e example implementation[Issue:Cannot GET /states] MAC OS

Need help on solving the above problem 'cannot GET /states' for http:/localhost:8081/states. I have gone through https://groups.google.com/forum/#!topic/pact-support/zGj8o6snf5c, it is very helpful but did not find the answer.

GitHub Repository URL:https://github.com/pactfoundation/pactjs/tree/master/examples/e2e

I have set up the Pact-js e2e example on my machine OS X EI Captain[10.11].

  1. Run the consumer test ./node_modules/.bin/mocha test/consumer.spec.js Got the successful output.

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

  1. Publish the tests node test/publish.js. Got the successful output.

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.

  1. Run the consumer and provider api npm run api. Got the successful output

Animal Profile Service listening on http://localhost:8081
Animal Matching Service listening on http://localhots:8080

  1. Run the provider test ./node_modules/.bin/mocha test/provider.spec.js.Got the error here

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)
'

Can you please help me in resolving the error on step 4. Another question on Step 3 is when I click on the link in the output it does not ask for username and password.

Thanks,
Sakshi

Upvotes: 0

Views: 298

Answers (2)

Matthew Fellows
Matthew Fellows

Reputation: 4065

Can you double check you have the latest code pulled down? Looks like a transitive depedency shifted which didn't like the existing content type. I patched it the other day.

Upvotes: 0

Matthew Fellows
Matthew Fellows

Reputation: 4065

Step 3 listed above is not necessary, it is simply to test and use the running APIs.

I suspect step 4 is unable to run the provider with the extra endpoints as it is already running on the same port in step 3 hence the failure. This would mean it is unable to find the endpoint /states during the verification process.

Close all processes and then run step 4 and this endpoint should be added, and the tests should pass.

Upvotes: 0

Related Questions