How to use the @pact-foundation/pact.synchronousBodyHandler function in @pact-foundation/pact

To help you get started, we’ve selected a few @pact-foundation/pact 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 pact-foundation / pact-js / examples / serverless / consumer / consumer.spec.js View on Github external
it("accepts a valid event", () => {
      return messagePact
        .expectsToReceive("a request to save an event")
        .withContent({
          id: like(1),
          event: like("something important"),
          type: term({ generate: "save", matcher: "^(save|update|cancel)$" }),
        })
        .withMetadata({
          "content-type": "application/json",
        })
        .verify(synchronousBodyHandler(consumeEvent))
    })
  })
github thombergs / code-examples / pact / pact-node-messages / src / consumer / hero-event-handler.spec.js View on Github external
it("should accept a valid hero created message", (done) => {
            messagePact
                .expectsToReceive("a hero created message")
                .withContent({
                    id: Matchers.like(42),
                    name: Matchers.like("Superman"),
                    superpower: Matchers.like("flying"),
                    universe: Matchers.term({generate: "DC", matcher: "^(DC|Marvel)$"})
                })
                .withMetadata({
                    "content-type": "application/json",
                })
                .verify(synchronousBodyHandler(HeroEventHandler.handleHeroCreatedEvent))
                .then(() => done(), (error) => done(error));
        }).timeout(5000);
github pact-foundation / pact-js / examples / messages / consumer / message-consumer.spec.ts View on Github external
it.skip("Does not accept an invalid dog", () => {
    return messagePact
      .given("some state")
      .expectsToReceive("a request for a dog")
      .withContent({
        name: "fido",
      })
      .withMetadata({
        "content-type": "application/json",
      })
      .verify(synchronousBodyHandler(dogApiHandler))
  })
})