Hello I've been trying to get an next.js example (...
# pact-js
c
Hello I've been trying to get an next.js example (using jest-pact adapter) working without success. I’ve installed an out of the box next.js application and tried to add an API app (jest-pact-example/pages/api/my_api.ts) and a jest-pact unit test (jest-pact-example/__tests__/my_api.ts) in the same way as shown in the Pact-JS V2 section of the following guide: https://github.com/pact-foundation/jest-pact But the mocked provider seems to never be reached by the axios calls as indicated by the following error message:
Copy code
Test failed for the following reasons:
 
       Mock server failed with the following mismatches:
 
       0) The following request was expected but not received:
           Method: GET
           Path: /health
Here is the code of my example: https://github.com/cyrusdevnomad/jest-pact-example The error is issued whenever I execute
npm run test
What could be the reason why the mock server is not reached? Thanks
y
Changing the method to the following (making it async and awaiting
client.getHealth()
Copy code
it("Testing the GET call", async () => {
      await client.getHealth().then((health: any) => {
        expect(health).toEqual("up");
        console.log(`health: response: ${health}`);
      });
    });
which I don't quite understand yet 🤷‍♂️ because it has a then chained off it. But it's late and that should get you generating a pact file at least
Also thank you very much for the reproducible example, top marks from me 🌮
💯 2
@Cyrus Devnomad 🌮
c
Yes, its working now indeed. Thank you very much. Nice to start my day with one problem solved and a taco on top of it 🙂
🙌 1
y
Fabulous! Good luck Cyrus and good morning