pact-foundation / pact-js-core

Core binaries for pact-js, a Contract Testing Framework. NOTE: If you are looking to do Pact contract testing in node, you almost certainly want pact-js, not pact-node.
https://docs.pact.io
MIT License
150 stars 79 forks source link

customProviderHeaders validation fails for well typed customProviderHeaders during verification #392

Closed adamwitko closed 2 years ago

adamwitko commented 2 years ago

Software versions

Issue Checklist

Please confirm the following:

Expected behaviour

Well formed customProviderHeaders are passed to the verification.

Actual behaviour

An error is thrown when executing the verification.

TypeError: customProviderHeaders

      32 |       : process.env.CI_COMMIT_BRANCH
      33 |
    > 34 |     const output = await verifyProvider(
         |                    ^
      35 |       {
      36 |         provider: 'delivery-promise-service',
      37 |         branch: branch!,

      at assertImpl (../../../../../pact-provider/node_modules/check-types/src/check-types.js:730:11)
      at assertPredicate (../../../../../pact-provider/node_modules/check-types/src/check-types.js:718:5)
      at ../../../../../pact-provider/node_modules/check-types/src/check-types.js:710:14
      at ../../../../../pact-provider/node_modules/@pact-foundation/pact-core/src/verifier/validateOptions.ts:245:22
          at Array.map (<anonymous>)
      at ../../../../../pact-provider/node_modules/@pact-foundation/pact-core/src/verifier/validateOptions.ts:244:13
          at Array.map (<anonymous>)
      at Object.validateOptions (../../../../../pact-provider/node_modules/@pact-foundation/pact-core/src/verifier/validateOptions.ts:232:5)
      at new Verifier (../../../../../pact-provider/node_modules/@pact-foundation/pact-core/src/verifier/index.ts:16:20)
      at Object.<anonymous>.exports.default (../../../../../pact-provider/node_modules/@pact-foundation/pact-core/src/verifier/index.ts:30:56)
      at Pact.verifyPacts (../../../../../pact-provider/node_modules/@pact-foundation/pact-core/src/pact.ts:156:27)
      at ../../../../../pact-provider/node_modules/@pact-foundation/src/dsl/verifier/verifier.ts:110:29
      at Object.<anonymous> (src/__tests__/pact/delivery-promise-service.verifier.spec.ts:34:20)

Steps to reproduce

Specify customProviderHeaders that adhere to the object type { [k: string]: string }.

Relevant log files

Please ensure you set logging to DEBUG and attach any relevant log files here (or link to a gist).

mefellows commented 2 years ago

Thanks Adam - leaving this open to support the backwards compatible type definition of string[]

mefellows commented 2 years ago

I've restored the previous type shape support to pact-core in #395 .