Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation needs updates #63

Open
llanni opened this issue Nov 26, 2024 · 0 comments
Open

Documentation needs updates #63

llanni opened this issue Nov 26, 2024 · 0 comments

Comments

@llanni
Copy link

llanni commented Nov 26, 2024

Hi @mdcruz,

Thank you for sharing this project and for your great book!

The documentation needs some updates:

  1. When running on local, these steps are also necessary in the command line:
export GITHUB_SHA=$(git rev-parse HEAD)
export GITHUB_BRANCH=$(git rev-parse --abbrev-ref HEAD)

Otherwise the command npm run publish:pact won't work.

  1. I think this command npm run start:graphql:server also invokes the first one npm run start:provider, right? In any case, to have both commands executed in 2 terminal instances (as the readme suggets), will have the 2nd failing on overlapping port 3001

  2. Please replace these variables:

export PACT_BROKER_URL=<PACT_BROKER_URL here>
export PACT_API_TOKEN=<API_TOKEN here>

With the actual names:

export PACT_BROKER_BASE_URL=<PACT_BROKER_URL here>
export PACT_BROKER_TOKEN=<API_TOKEN here>

Also I think it helps to specify that the PACT_BROKER_BASE_URL refers to the https://<DOMAIN-NAME>.pactflow.io/ at least for basic free accounts on path flow.

That being said, still the command: npm run test:provider

Fails with this error:

   ● Pact Verification › should validate the expectations of movie-consumer

    listen EADDRINUSE: address already in use :::3001

      3 |
      4 | const port = '3001';
    > 5 | const app = server.listen(port, () => console.log(`Listening on port ${port}...`));
        |                    ^
      6 |
      7 | importData();
      8 |

      at Function.listen (node_modules/express/lib/application.js:635:24)
      at Object.listen (provider/provider-contract.spec.js:5:20)

  ● Pact Verification › should validate the expectations of movie-consumer

And same for the second call: ``

 ● GraphQL example › When a query to list a single movie on /graphql is made › returns the correct response

   TypeError: Cannot read properties of undefined (reading 'movie')

     110 |     test('returns the correct response', async () => {
     111 |       const response = await getMovieById(1);
   > 112 |       expect(response.movie).toEqual(EXPECTED_BODY);
         |                       ^
     113 |     });
     114 |   });
     115 | });

     at Object.movie (graphql/consumer/graphql-client-contract.spec.js:112:23)

 ● GraphQL example › When a query to list a single movie on /graphql is made › returns the correct response

   Pact verification failed - expected interactions did not match actual.

     26 |
     27 |   // Verify the consumer expectations
   > 28 |   afterEach(() => provider.verify());
        |                            ^
     29 |
     30 |   describe('When a query to list all movies on /graphql is made', () => {
     31 |     beforeAll(() => {

     at new VerificationError (node_modules/@pact-foundation/pact/src/errors/verificationError.js:21:42)
     at Pact.Object.<anonymous>.Pact.verify (node_modules/@pact-foundation/src/httpPact/index.ts:215:13)
     at Object.verify (graphql/consumer/graphql-client-contract.spec.js:28:28)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 passed, 2 total
Snapshots:   0 total
Time:        0.56 s, estimated 1 s
Ran all test suites matching /graphql\/consumer\/graphql-client-contract.spec.js/i.

I guess this is not expected, right?
Or maybe am I doing something wrong?
I am testing on local, using a MBA M1.

Out of curiosity, if I go on: http://localhost:3001/ I get: the error: Cannot GET /, is this a symptom of something not right?

Thanks,

Leonardo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant