<#1106 Request validation fails after upgrade to v...
# pact-js-development
g
#1106 Request validation fails after upgrade to v12 Issue created by pieter-stek Software versions • OS: Windows 11 • Consumer Pact library: PactJS 12.1.0 • Provider Pact library: au.com.dius.pact.providerjunit54.6.1 • Node Version: 16.18.0 Issue Checklist Please confirm the following: ☑︎ I have upgraded to the latest ☑︎ I have the read the FAQs in the Readme ☑︎ I have triple checked, that there are no unhandled promises in my code and have read the section on intermittent test failures ☑︎ I have set my log level to debug and attached a log file showing the complete request/response cycle ☐ For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem Expected behaviour I updated PactJS from 11.0.2 to 12.1.0 and without any other changes the contract test started failing. Actual behaviour
Copy code
Mock server failed with the following mismatches:

        0) The following request was incorrect:

                PUT /picking-capacity/capacities/1

                      'Content-Type': Expected value 'application/json' at index 1 but was missing
Steps to reproduce
Copy code
import { PactV3 } from "@pact-foundation/pact";
import axios from "axios";
import path from "path";

const provider = new PactV3({
    port: 8082,
    dir: path.resolve(process.cwd(), "pacts"),
    cors: true,
    pactfileWriteMode: "update",
    consumer: "application",
    provider: "applicationApi",
    logLevel: "debug",
  });
  
  describe("serviceUnderTest", () => {
  
    it("should validate PUT request", async () => {
      await provider.addInteraction({
        states: [{ description: "resource exists" }],
        uponReceiving: "update",
        withRequest: {
          method: "PUT",
          path: "/resource/1",
          headers: {
            "Content-Type": "application/json",
          },
          body: {},
        },
        willRespondWith: {
          status: 200,
          headers: {
            "Content-Type": "application/json",
          },
          body: {},
        },
      });
  
      await provider.executeTest(async () => {
        await axios.put("<http://localhost:8082/resource/1>", {});
      });
    });
  })
Relevant log files pact-debug.log pact-foundation/pact-js