How to use @pact-foundation/pact-web - 3 common examples

To help you get started, we’ve selected a few @pact-foundation/pact-web examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thombergs / code-examples / pact / pact-angular / src / app / user.service.pact.spec.ts View on Github external
beforeAll(function (done) {
    provider = new PactWeb({
      consumer: 'ui',
      provider: 'userservice',
      port: 1234,
      host: '127.0.0.1',
    });

    // required for slower CI environments
    setTimeout(done, 2000);

    // Required if run with `singleRun: false`
    provider.removeInteractions();
  });
github thombergs / code-examples / pact / pact-angular / src / app / user.service.pact.spec.ts View on Github external
beforeAll((done) => {
      provider.addInteraction({
        state: `person 42 exists`,
        uponReceiving: 'a request to PUT a person',
        withRequest: {
          method: 'PUT',
          path: '/user-service/users/42',
          body: Matchers.somethingLike(expectedUser),
          headers: {
            'Content-Type': 'application/json'
          }
        },
        willRespondWith: {
          status: 200,
          body: Matchers.somethingLike(expectedUser)
        }
      }).then(done, error => done.fail(error));
    });
github thombergs / code-examples / pact / pact-angular / src / app / user.service.pact.spec.ts View on Github external
beforeAll((done) => {
      provider.addInteraction({
        state: `provider accepts a new person`,
        uponReceiving: 'a request to POST a person',
        withRequest: {
          method: 'POST',
          path: '/user-service/users',
          body: expectedUser,
          headers: {
            'Content-Type': 'application/json'
          }
        },
        willRespondWith: {
          status: 201,
          body: Matchers.somethingLike({
              id: createdUserId
          }),
          headers: {
            'Content-Type': 'application/json'
          }
        }
      }).then(done, error => done.fail(error));
    });

@pact-foundation/pact-web

Pact for the browser

MIT
Latest version published 2 years ago

Package Health Score

70 / 100
Full package analysis