Hello, I'm new to writing contract tests and was t...
# pact-js
a
Hello, I'm new to writing contract tests and was trying to set up a test using Pact but am running into an odd error when I run the test file. I was hoping someone might be able to point me in the right direction here. Will post code in thread.
Copy code
import axios from 'axios';

import { MatchersV3 } from '@pact-foundation/pact';
import provider from './pact';

import { getProcessingAccounts } from '../../src/rest/processing-accounts';
import { processingAccountMock } from '../mocks/processing-accounts';

const { like } = MatchersV3;


describe('onboarding/risk api test', () => {
  describe('getting processing account status', () => {
    beforeAll(() => {
      provider
        .given('I have a list of processing accounts')
        .uponReceiving('a request for all processing accounts for a business')
        .withRequest({
          method: 'GET',
          headers: {
            Authorization: like('12345')
          },
          url: '/v2/processingAccounts',
          query: {
            businessId: '111222333'
          }
        })
        .willRespondWith({
          status: 200,
          body: like(processingAccountMock)
        });
    });

    it('should return the correct processing account format', async () => {
      await provider.executeTest(async (mockserver) => {
        axios.defaults.baseURL = mockserver.url;

        const response = await getProcessingAccounts('111222333', '12345');

        expect(response).toStrictEqual(processingAccountMock);
      });
    });
  });
});
y
withRequest should have
path
not
url
Copy code
provider
      .given('I have a list of dogs')
      .uponReceiving('a request for all dogs with the builder pattern')
      .withRequest({
        method: 'GET',
        path: '/dogs',
        query: { from: 'today' },
        headers: { Accept: 'application/json' },
      })
      .willRespondWith({
        status: 200,
        headers: { 'Content-Type': 'application/json' },
        body: EXPECTED_BODY,
      });
thankyou 2
a
Ahh, that makes sense, I had been following a different tutorial before and switched but forgot to change that, thank you