How to use the @pact-foundation/pact.MessageConsumerPact 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 thombergs / code-examples / pact / pact-node-messages / src / consumer / hero-event-handler.spec.js View on Github external
describe("message consumer", () => {

    const messagePact = new MessageConsumerPact({
        consumer: "node-message-consumer",
        provider: "node-message-provider",
        dir: path.resolve(process.cwd(), "pacts"),
        pactfileWriteMode: "update",
        logLevel: "info",
    });

    describe("'hero created' message Handler", () => {

        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"),
github pact-foundation / pact-js / examples / serverless / consumer / consumer.spec.js View on Github external
describe("Serverless consumer tests", () => {
  const messagePact = new MessageConsumerPact({
    consumer: "SNSPactEventConsumer",
    dir: path.resolve(process.cwd(), "pacts"),
    provider: "SNSPactEventProvider",
  })

  describe("receive a pact event", () => {
    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",
github pact-foundation / pact-js / examples / messages / consumer / message-consumer.spec.ts View on Github external
describe("Message consumer tests", () => {
  const messagePact = new MessageConsumerPact({
    consumer: "MyJSMessageConsumer",
    dir: path.resolve(process.cwd(), "pacts"),
    pactfileWriteMode: "update",
    provider: "MyJSMessageProvider",
    logLevel: "info",
  })

  describe("receive dog event", () => {
    it("accepts a valid dog", () => {
      return messagePact
        .given("some state")
        .expectsToReceive("a request for a dog")
        .withContent({
          id: like(1),
          name: like("rover"),
          type: term({ generate: "bulldog", matcher: "^(bulldog|sheepdog)$" }),